mirror of
https://github.com/stonega/tsacdop
synced 2025-02-03 08:57:33 +01:00
7ba0552717
modified: lib/episodes/episodedetail.dart modified: lib/home/appbar/about.dart modified: lib/home/appbar/addpodcast.dart modified: lib/home/appbar/importompl.dart modified: lib/home/appbar/popupmenu.dart modified: lib/home/audio_player.dart modified: lib/home/audiopanel.dart modified: lib/home/homescroll.dart modified: lib/home/hometab.dart modified: lib/local_storage/key_value_storage.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
186 lines
5.2 KiB
Dart
186 lines
5.2 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:tsacdop/class/episodebrief.dart';
|
|
import 'package:tsacdop/local_storage/sqflite_localpodcast.dart';
|
|
import 'package:tsacdop/util/episodegrid.dart';
|
|
|
|
class MainTab extends StatefulWidget {
|
|
@override
|
|
_MainTabState createState() => _MainTabState();
|
|
}
|
|
|
|
class _MainTabState extends State<MainTab> with TickerProviderStateMixin {
|
|
TabController _controller;
|
|
Decoration getIndicator(BuildContext context) {
|
|
return UnderlineTabIndicator(
|
|
borderSide: BorderSide(color: Theme.of(context).accentColor, width: 2),
|
|
insets: EdgeInsets.only(
|
|
left: 10.0,
|
|
right: 10.0,
|
|
top: 10.0,
|
|
));
|
|
}
|
|
|
|
@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(
|
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
|
height: 50,
|
|
alignment: Alignment.centerLeft,
|
|
child: TabBar(
|
|
isScrollable: true,
|
|
labelPadding: EdgeInsets.all(10.0),
|
|
controller: _controller,
|
|
indicator: getIndicator(context),
|
|
tabs: <Widget>[
|
|
Text(
|
|
'Recent Update',
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
Text(
|
|
'Favorites',
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
Text(
|
|
'Downloads',
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
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());
|
|
},
|
|
);
|
|
}
|
|
}
|