2020-02-12 16:16:46 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:flutter/foundation.dart';
|
2020-02-22 13:25:06 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2020-02-11 14:01:57 +01:00
|
|
|
import 'package:flutter_html/flutter_html.dart';
|
2020-02-20 10:09:21 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
|
2020-05-06 18:50:32 +02:00
|
|
|
import '../state/podcast_group.dart';
|
|
|
|
import '../type/podcastlocal.dart';
|
|
|
|
import '../local_storage/sqflite_localpodcast.dart';
|
2020-07-07 17:29:21 +02:00
|
|
|
import 'podcast_detail.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
import '../util/pageroute.dart';
|
2020-06-02 16:05:49 +02:00
|
|
|
import '../util/context_extension.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2020-02-21 16:04:02 +01:00
|
|
|
void getDescription(String id) async {
|
2020-02-09 13:29:09 +01:00
|
|
|
var dbHelper = DBHelper();
|
2020-02-21 16:04:02 +01:00
|
|
|
String description = await dbHelper.getFeedDescription(id);
|
2020-02-09 13:29:09 +01:00
|
|
|
_description = description;
|
|
|
|
setState(() {
|
|
|
|
_load = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_load = false;
|
2020-02-21 16:04:02 +01:00
|
|
|
getDescription(widget.podcastLocal.id);
|
2020-02-09 13:29:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-02-20 16:44:42 +01:00
|
|
|
var _groupList = Provider.of<GroupList>(context, listen: false);
|
2020-07-07 17:29:21 +02:00
|
|
|
final s = context.s;
|
2020-02-09 13:29:09 +01:00
|
|
|
return AlertDialog(
|
2020-03-03 17:04:23 +01:00
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.0))),
|
2020-06-02 16:05:49 +02:00
|
|
|
titlePadding: EdgeInsets.only(
|
|
|
|
top: 20, left: 20, right: context.width / 3, bottom: 20),
|
2020-02-09 13:29:09 +01:00
|
|
|
actions: <Widget>[
|
|
|
|
FlatButton(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
onPressed: () {
|
2020-02-20 16:44:42 +01:00
|
|
|
_groupList.removePodcast(widget.podcastLocal.id);
|
2020-02-09 13:29:09 +01:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
textColor: Colors.red,
|
|
|
|
child: Text(
|
2020-07-07 17:29:21 +02:00
|
|
|
s.remove,
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
title: Text(widget.podcastLocal.title),
|
2020-06-02 16:05:49 +02:00
|
|
|
content: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
child: 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(),
|
|
|
|
],
|
|
|
|
),
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PodcastList extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_PodcastListState createState() => _PodcastListState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PodcastListState extends State<PodcastList> {
|
2020-02-12 16:16:46 +01:00
|
|
|
Future<List<PodcastLocal>> getPodcastLocal() async {
|
|
|
|
var dbHelper = DBHelper();
|
2020-02-20 10:09:21 +01:00
|
|
|
var podcastList = await dbHelper.getPodcastLocalAll();
|
2020-02-12 16:16:46 +01:00
|
|
|
return podcastList;
|
|
|
|
}
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-02-15 08:53:26 +01:00
|
|
|
double _width = MediaQuery.of(context).size.width;
|
2020-02-22 13:25:06 +01:00
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
|
|
|
|
systemNavigationBarColor: Theme.of(context).primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
systemNavigationBarIconBrightness:
|
|
|
|
Theme.of(context).accentColorBrightness,
|
2020-02-20 10:09:21 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
2020-07-07 17:29:21 +02:00
|
|
|
title: Text(context.s.podcast(2)),
|
2020-03-19 20:58:30 +01:00
|
|
|
centerTitle: true,
|
|
|
|
),
|
|
|
|
body: SafeArea(
|
|
|
|
child: Container(
|
2020-02-22 13:25:06 +01:00
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
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(
|
2020-03-03 17:04:23 +01:00
|
|
|
gridDelegate:
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
2020-02-22 13:25:06 +01:00
|
|
|
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: () {
|
2020-03-03 17:04:23 +01:00
|
|
|
showGeneralDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: true,
|
|
|
|
barrierLabel:
|
|
|
|
MaterialLocalizations.of(context)
|
|
|
|
.modalBarrierDismissLabel,
|
|
|
|
barrierColor: Colors.black54,
|
|
|
|
transitionDuration:
|
|
|
|
const Duration(milliseconds: 200),
|
|
|
|
pageBuilder: (BuildContext context,
|
|
|
|
Animation animaiton,
|
|
|
|
Animation secondaryAnimation) =>
|
|
|
|
AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness:
|
|
|
|
Brightness.light,
|
|
|
|
systemNavigationBarColor:
|
|
|
|
Theme.of(context)
|
|
|
|
.brightness ==
|
|
|
|
Brightness.light
|
|
|
|
? Color.fromRGBO(
|
|
|
|
113, 113, 113, 1)
|
|
|
|
: Color.fromRGBO(
|
|
|
|
15, 15, 15, 1),
|
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: AboutPodcast(
|
|
|
|
podcastLocal:
|
|
|
|
snapshot.data[index]),
|
2020-03-03 17:04:23 +01:00
|
|
|
));
|
2020-02-22 13:25:06 +01:00
|
|
|
},
|
|
|
|
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}")),
|
|
|
|
),
|
2020-02-20 10:09:21 +01:00
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(4.0),
|
|
|
|
child: Text(
|
|
|
|
snapshot.data[index].title,
|
|
|
|
textAlign: TextAlign.center,
|
2020-03-01 13:17:06 +01:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.bodyText1,
|
2020-02-22 13:25:06 +01:00
|
|
|
maxLines: 2,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
childCount: snapshot.data.length,
|
|
|
|
),
|
|
|
|
),
|
2020-02-20 10:09:21 +01:00
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Text('NoData');
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2020-02-20 10:09:21 +01:00
|
|
|
),
|
2020-02-09 13:29:09 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|