2020-02-09 13:29:09 +01:00
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
2020-02-11 14:48:11 +01:00
|
|
|
import 'package:tsacdop/class/episodebrief.dart';
|
|
|
|
import 'package:tsacdop/class/sqflite_localpodcast.dart';
|
|
|
|
import 'package:tsacdop/util/episodegrid.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
|
|
|
|
class MainTab extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_MainTabState createState() => _MainTabState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MainTabState extends State<MainTab> with TickerProviderStateMixin {
|
|
|
|
TabController _controller;
|
|
|
|
Decoration getIndicator() {
|
|
|
|
return const UnderlineTabIndicator(
|
|
|
|
borderSide: BorderSide(color: Colors.red, width: 2),
|
2020-02-11 14:01:57 +01:00
|
|
|
insets: EdgeInsets.only(left:10.0,right: 10.0, top:10.0,)
|
|
|
|
);}
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_controller = TabController(length: 3, vsync: this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
2020-02-11 14:01:57 +01:00
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
2020-02-09 13:29:09 +01:00
|
|
|
height: 50,
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: TabBar(
|
|
|
|
isScrollable: true,
|
|
|
|
labelPadding:
|
2020-02-11 14:01:57 +01:00
|
|
|
EdgeInsets.all(10.0),
|
2020-02-09 13:29:09 +01:00
|
|
|
controller: _controller,
|
|
|
|
labelColor: Colors.red,
|
|
|
|
unselectedLabelColor: Colors.black,
|
|
|
|
indicator: getIndicator(),
|
|
|
|
tabs: <Widget>[
|
|
|
|
Text('Recent Update',style: TextStyle(fontWeight: FontWeight.bold),),
|
2020-02-11 14:01:57 +01:00
|
|
|
Text('Favorites',style: TextStyle(fontWeight: FontWeight.bold),),
|
|
|
|
Text('Downloads',style: TextStyle(fontWeight: FontWeight.bold),),
|
2020-02-09 13:29:09 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
child: TabBarView(
|
|
|
|
controller: _controller,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
child: RecentUpdate()),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
child: MyFavorite()),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
child: MyDownload()),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class RecentUpdate extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_RecentUpdateState createState() => _RecentUpdateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _RecentUpdateState extends State<RecentUpdate> {
|
|
|
|
Future<List<EpisodeBrief>> _getRssItem() async {
|
|
|
|
var dbHelper = DBHelper();
|
|
|
|
List<EpisodeBrief> episodes = await dbHelper.getRecentRssItem();
|
|
|
|
return episodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return FutureBuilder<List<EpisodeBrief>>(
|
|
|
|
future: _getRssItem(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasError) print(snapshot.error);
|
|
|
|
return (snapshot.hasData)
|
|
|
|
? EpisodeGrid(podcast: snapshot.data, showDownload: false, showFavorite: false, showNumber: false, heroTag: 'recent',)
|
|
|
|
: Center(child: CircularProgressIndicator());
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyFavorite extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_MyFavoriteState createState() => _MyFavoriteState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyFavoriteState extends State<MyFavorite> {
|
|
|
|
Future<List<EpisodeBrief>> _getLikedRssItem() async {
|
|
|
|
var dbHelper = DBHelper();
|
|
|
|
List<EpisodeBrief> episodes =await dbHelper.getLikedRssItem();
|
|
|
|
return episodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return FutureBuilder<List<EpisodeBrief>>(
|
|
|
|
future: _getLikedRssItem(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasError) print(snapshot.error);
|
|
|
|
return (snapshot.hasData)
|
|
|
|
? EpisodeGrid(podcast: snapshot.data, showDownload: false, showFavorite: false, showNumber: false, heroTag: 'favorite',)
|
|
|
|
: Center(child: CircularProgressIndicator());
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyDownload extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_MyDownloadState createState() => _MyDownloadState();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _MyDownloadState extends State<MyDownload> {
|
|
|
|
Future<List<EpisodeBrief>> _getDownloadedRssItem() async {
|
|
|
|
var dbHelper = DBHelper();
|
|
|
|
List<EpisodeBrief> episodes =await dbHelper.getDownloadedRssItem();
|
|
|
|
return episodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return FutureBuilder<List<EpisodeBrief>>(
|
|
|
|
future: _getDownloadedRssItem(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasError) print(snapshot.error);
|
|
|
|
return (snapshot.hasData)
|
|
|
|
? EpisodeGrid(podcast: snapshot.data, showDownload: true, showFavorite: false, showNumber: false, heroTag: 'download',)
|
|
|
|
: Center(child: CircularProgressIndicator());
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|