1
0
mirror of https://github.com/stonega/tsacdop synced 2024-12-17 02:39:28 +01:00
tsacdop-podcast-app-android/lib/podcasts/podcastdetail.dart
stonegate 9d4bbc895a modified: .circleci/config.yml
modified:   lib/class/episodebrief.dart
	modified:   lib/class/podcast_group.dart
	deleted:    lib/class/podcastrss.dart
	deleted:    lib/class/podcastrss.g.dart
	deleted:    lib/class/podcasts.dart
	deleted:    lib/class/podcasts.g.dart
	modified:   lib/episodes/episodedetail.dart
	modified:   lib/home/appbar/about.dart
	modified:   lib/home/appbar/addpodcast.dart
	modified:   lib/home/appbar/popupmenu.dart
	modified:   lib/home/homescroll.dart
	modified:   lib/local_storage/sqflite_localpodcast.dart
	modified:   lib/main.dart
	modified:   lib/podcasts/podcastdetail.dart
	modified:   lib/podcasts/podcastgroup.dart
	modified:   lib/podcasts/podcastlist.dart
	modified:   lib/podcasts/podcastmanage.dart
	modified:   lib/util/episodegrid.dart
	modified:   lib/webfeed/domain/rss_itunes.dart
	modified:   pubspec.lock
	modified:   pubspec.yaml
2020-02-21 23:04:02 +08:00

69 lines
2.3 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:tsacdop/class/podcastlocal.dart';
import 'package:tsacdop/class/episodebrief.dart';
import 'package:tsacdop/local_storage/sqflite_localpodcast.dart';
import 'package:tsacdop/util/episodegrid.dart';
class PodcastDetail extends StatefulWidget {
PodcastDetail({Key key, this.podcastLocal}) : super(key: key);
final PodcastLocal podcastLocal;
@override
_PodcastDetailState createState() => _PodcastDetailState();
}
class _PodcastDetailState extends State<PodcastDetail> {
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
GlobalKey<RefreshIndicatorState>();
Future _updateRssItem(PodcastLocal podcastLocal) async {
var dbHelper = DBHelper();
final result = await dbHelper.updatePodcastRss(podcastLocal);
result == 0 ?
Fluttertoast.showToast(
msg: 'No Update',
gravity: ToastGravity.TOP,
)
: Fluttertoast.showToast(
msg: 'Updated $result Episodes',
gravity: ToastGravity.TOP,
);
if(mounted) setState(() {});
}
Future<List<EpisodeBrief>> _getRssItem(PodcastLocal podcastLocal) async {
print(podcastLocal.id);
var dbHelper = DBHelper();
List<EpisodeBrief> episodes = await
dbHelper.getRssItem(podcastLocal.id);
return episodes;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.podcastLocal.title,),
elevation: 0.0,
backgroundColor: Colors.grey[100],
centerTitle: true,
),
body: RefreshIndicator(
key: _refreshIndicatorKey,
color: Colors.blue[500],
onRefresh: () => _updateRssItem(widget.podcastLocal),
child: FutureBuilder<List<EpisodeBrief>>(
future: _getRssItem(widget.podcastLocal),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return (snapshot.hasData)
? EpisodeGrid(podcast: snapshot.data, showDownload: true, showFavorite: true, showNumber: true, heroTag: 'podcast',)
: Center(child: CircularProgressIndicator());
},
)),
);
}
}