1
0
mirror of https://github.com/stonega/tsacdop synced 2024-12-16 10:22:23 +01:00
tsacdop-podcast-app-android/lib/podcasts/podcastlist.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

202 lines
6.7 KiB
Dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:provider/provider.dart';
import 'package:tsacdop/class/podcast_group.dart';
import 'package:tsacdop/class/podcastlocal.dart';
import 'package:tsacdop/local_storage/sqflite_localpodcast.dart';
import 'package:tsacdop/podcasts/podcastdetail.dart';
import 'package:tsacdop/util/pageroute.dart';
class AboutPodcast extends StatefulWidget {
final PodcastLocal podcastLocal;
AboutPodcast({this.podcastLocal, Key key}) : super(key: key);
@override
_AboutPodcastState createState() => _AboutPodcastState();
}
class _AboutPodcastState extends State<AboutPodcast> {
String _description;
bool _load;
void getDescription(String id) async {
var dbHelper = DBHelper();
String description = await dbHelper.getFeedDescription(id);
_description = description;
setState(() {
_load = true;
});
}
@override
void initState() {
super.initState();
_load = false;
getDescription(widget.podcastLocal.id);
}
@override
Widget build(BuildContext context) {
var _groupList = Provider.of<GroupList>(context, listen: false);
return AlertDialog(
actions: <Widget>[
FlatButton(
padding: EdgeInsets.all(10.0),
onPressed: () {
_groupList.removePodcast(widget.podcastLocal.id);
Navigator.of(context).pop();
},
color: Colors.grey[200],
textColor: Colors.red,
child: Text(
'UNSUBSCRIBE',
),
),
],
title: Text(widget.podcastLocal.title),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
!_load
? Center()
: _description != null ? Html(data: _description) : Center(),
(widget.podcastLocal.author != null)
? Text(widget.podcastLocal.author,
style: TextStyle(color: Colors.blue))
: Center(),
],
),
);
}
}
class PodcastList extends StatefulWidget {
@override
_PodcastListState createState() => _PodcastListState();
}
class _PodcastListState extends State<PodcastList> {
Future<List<PodcastLocal>> getPodcastLocal() async {
var dbHelper = DBHelper();
var podcastList = await dbHelper.getPodcastLocalAll();
return podcastList;
}
@override
Widget build(BuildContext context) {
double _width = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title: Text('Podcasts'),
centerTitle: true,
backgroundColor: Colors.grey[100],
elevation: 0,
),
body: Container(
color: Colors.grey[100],
child: FutureBuilder<List<PodcastLocal>>(
future: getPodcastLocal(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return CustomScrollView(
primary: false,
slivers: <Widget>[
SliverPadding(
padding: const EdgeInsets.all(10.0),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: 0.8,
crossAxisCount: 3,
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return InkWell(
onTap: () {
Navigator.push(
context,
ScaleRoute(
page: PodcastDetail(
podcastLocal: snapshot.data[index],
)),
);
},
onLongPress: () {
showDialog(
context: context,
builder: (BuildContext context) => AboutPodcast(
podcastLocal: snapshot.data[index]),
).then((_) => setState(() {}));
},
child: Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
height: 10.0,
),
ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(_width / 8)),
child: Container(
height: _width / 4,
width: _width / 4,
child: Image.file(File(
"${snapshot.data[index].imagePath}")),
),
),
Container(
padding: EdgeInsets.all(4.0),
child: Text(
snapshot.data[index].title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
color: Colors.black.withOpacity(0.5),
),
maxLines: 2,
),
),
],
),
),
);
},
childCount: snapshot.data.length,
),
),
),
],
);
}
return Text('NoData');
},
),
),
);
}
}
class Podcast extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.grey[100],
elevation: 0,
centerTitle: true,
title: Text('Podcasts'),
),
body: Container(child: PodcastList()),
);
}
}