modified: lib/home/home.dart

This commit is contained in:
stonegate 2020-05-19 01:32:32 +08:00
parent 6ebe9a4a3c
commit 860e2ed626
3 changed files with 372 additions and 316 deletions

View File

@ -4,7 +4,7 @@ import 'package:tsacdop/util/custompaint.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:line_icons/line_icons.dart';
const String version = '0.2.4';
const String version = '0.3.0';
class AboutApp extends StatelessWidget {
_launchUrl(String url) async {

View File

@ -451,199 +451,221 @@ class _RecentUpdateState extends State<_RecentUpdate>
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return (snapshot.hasData)
? NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification scrollInfo) {
if (scrollInfo.metrics.pixels ==
scrollInfo.metrics.maxScrollExtent &&
snapshot.data.length == _top) _loadMoreEpisode();
return true;
},
child: CustomScrollView(
key: PageStorageKey<String>('update'),
physics: const AlwaysScrollableScrollPhysics(),
slivers: <Widget>[
SliverToBoxAdapter(
child: Container(
height: 40,
color: context.primaryColor,
child: Row(
children: <Widget>[
Consumer<GroupList>(
builder: (context, groupList, child) =>
Material(
color: Colors.transparent,
child: PopupMenuButton<String>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(10))),
elevation: 1,
tooltip: 'Groups fliter',
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 20),
height: 50,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(_groupName),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 5),
),
Icon(
LineIcons.filter_solid,
size: 18,
)
],
)),
itemBuilder: (context) => [
PopupMenuItem(
child: Text('All'), value: 'All')
]..addAll(groupList.groups
.map<PopupMenuEntry<String>>((e) =>
PopupMenuItem(
value: e.name,
child: Text(e.name)))
.toList()),
onSelected: (value) {
if (value == 'All') {
setState(() {
_groupName = 'All';
_group = ['All'];
});
} else {
groupList.groups.forEach((group) {
if (group.name == value) {
? snapshot.data.length == 0
? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(LineIcons.cloud_download_alt_solid,
size: 80, color: Colors.grey[500]),
Padding(padding: EdgeInsets.symmetric(vertical: 10)),
Text(
'No episode received yet',
style: TextStyle(color: Colors.grey[500]),
)
],
),
)
: NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification scrollInfo) {
if (scrollInfo.metrics.pixels ==
scrollInfo.metrics.maxScrollExtent &&
snapshot.data.length == _top) _loadMoreEpisode();
return true;
},
child: CustomScrollView(
key: PageStorageKey<String>('update'),
physics: const AlwaysScrollableScrollPhysics(),
slivers: <Widget>[
SliverToBoxAdapter(
child: Container(
height: 40,
color: context.primaryColor,
child: Row(
children: <Widget>[
Consumer<GroupList>(
builder: (context, groupList, child) =>
Material(
color: Colors.transparent,
child: PopupMenuButton<String>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(10))),
elevation: 1,
tooltip: 'Groups fliter',
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 20),
height: 50,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(_groupName),
Padding(
padding:
EdgeInsets.symmetric(
horizontal: 5),
),
Icon(
LineIcons.filter_solid,
size: 18,
)
],
)),
itemBuilder: (context) => [
PopupMenuItem(
child: Text('All'),
value: 'All')
]..addAll(groupList.groups
.map<PopupMenuEntry<String>>(
(e) => PopupMenuItem(
value: e.name,
child: Text(e.name)))
.toList()),
onSelected: (value) {
if (value == 'All') {
setState(() {
_groupName = value;
_group = group.podcastList;
_groupName = 'All';
_group = ['All'];
});
} else {
groupList.groups.forEach((group) {
if (group.name == value) {
setState(() {
_groupName = value;
_group = group.podcastList;
});
}
});
}
});
}
},
},
),
),
),
),
),
Spacer(),
FutureBuilder<int>(
future: _getUpdateCounts(_group),
initialData: 0,
builder: (context, snapshot) {
return snapshot.data != 0
? Material(
color: Colors.transparent,
child: IconButton(
tooltip:
'Add new episodes to playlist',
icon:
// Icon(Icons.playlist_add),
SizedBox(
height: 16,
width: 21,
child: CustomPaint(
painter: AddToPlaylistPainter(
context
.textTheme
.bodyText1
.color,
Colors.red))),
onPressed: () async {
await audio
.addNewEpisode(_group);
if (mounted)
setState(() {});
Fluttertoast.showToast(
msg: _groupName == 'All'
? '${snapshot.data} episode added to playlist'
: '${snapshot.data} episode in $_groupName added to playlist',
gravity:
ToastGravity.BOTTOM,
);
}),
)
: Material(
color: Colors.transparent,
child: IconButton(
tooltip:
'Add new episodes to playlist',
icon:
// Icon(Icons.playlist_add),
SizedBox(
height: 16,
width: 21,
child: CustomPaint(
painter:
AddToPlaylistPainter(
context
.textTheme
.bodyText1
.color,
context
.textTheme
.bodyText1
.color,
))),
onPressed: () {}),
);
}),
Material(
color: Colors.transparent,
child: IconButton(
tooltip: 'Change layout',
padding: EdgeInsets.zero,
onPressed: () {
if (_layout == Layout.three)
setState(() {
_layout = Layout.two;
});
else
setState(() {
_layout = Layout.three;
});
},
icon: _layout == Layout.three
? SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
0,
context.textTheme.bodyText1
.color),
),
)
: SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
1,
context.textTheme.bodyText1
.color),
),
),
)),
],
)),
),
EpisodeGrid(
episodes: snapshot.data,
layout: _layout,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return _loadMore
? Container(
height: 2, child: LinearProgressIndicator())
: Center();
},
childCount: 1,
),
),
]),
)
Spacer(),
FutureBuilder<int>(
future: _getUpdateCounts(_group),
initialData: 0,
builder: (context, snapshot) {
return snapshot.data != 0
? Material(
color: Colors.transparent,
child: IconButton(
tooltip:
'Add new episodes to playlist',
icon:
// Icon(Icons.playlist_add),
SizedBox(
height: 16,
width: 21,
child: CustomPaint(
painter: AddToPlaylistPainter(
context
.textTheme
.bodyText1
.color,
Colors
.red))),
onPressed: () async {
await audio
.addNewEpisode(
_group);
if (mounted)
setState(() {});
Fluttertoast.showToast(
msg: _groupName ==
'All'
? '${snapshot.data} episode added to playlist'
: '${snapshot.data} episode in $_groupName added to playlist',
gravity: ToastGravity
.BOTTOM,
);
}),
)
: Material(
color: Colors.transparent,
child: IconButton(
tooltip:
'Add new episodes to playlist',
icon:
// Icon(Icons.playlist_add),
SizedBox(
height: 16,
width: 21,
child:
CustomPaint(
painter:
AddToPlaylistPainter(
context
.textTheme
.bodyText1
.color,
context
.textTheme
.bodyText1
.color,
))),
onPressed: () {}),
);
}),
Material(
color: Colors.transparent,
child: IconButton(
tooltip: 'Change layout',
padding: EdgeInsets.zero,
onPressed: () {
if (_layout == Layout.three)
setState(() {
_layout = Layout.two;
});
else
setState(() {
_layout = Layout.three;
});
},
icon: _layout == Layout.three
? SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
0,
context.textTheme
.bodyText1.color),
),
)
: SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
1,
context.textTheme
.bodyText1.color),
),
),
)),
],
)),
),
EpisodeGrid(
episodes: snapshot.data,
layout: _layout,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return _loadMore
? Container(
height: 2,
child: LinearProgressIndicator())
: Center();
},
childCount: 1,
),
),
]),
)
: Center();
},
);
@ -696,129 +718,145 @@ class _MyFavoriteState extends State<_MyFavorite>
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return (snapshot.hasData)
? NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification scrollInfo) {
if (scrollInfo.metrics.pixels ==
scrollInfo.metrics.maxScrollExtent &&
snapshot.data.length == _top) _loadMoreEpisode();
return true;
},
child: CustomScrollView(
key: PageStorageKey<String>('favorite'),
slivers: <Widget>[
SliverToBoxAdapter(
child: Container(
height: 40,
color: context.primaryColor,
child: Row(
children: <Widget>[
Material(
color: Colors.transparent,
child: PopupMenuButton<int>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(10))),
elevation: 1,
tooltip: 'Sort By',
child: Container(
height: 50,
padding:
EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('Sory by'),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 5),
),
Icon(
_sortBy == 0
? LineIcons
.cloud_download_alt_solid
: LineIcons.heartbeat_solid,
size: 18,
)
],
)),
itemBuilder: (context) => [
PopupMenuItem(
value: 0,
child: Text('Update Date'),
),
PopupMenuItem(
value: 1,
child: Text('Like Date'),
)
],
onSelected: (value) {
if (value == 0)
setState(() => _sortBy = 0);
else if (value == 1)
setState(() => _sortBy = 1);
},
),
),
Spacer(),
Material(
color: Colors.transparent,
child: IconButton(
padding: EdgeInsets.zero,
onPressed: () {
if (_layout == Layout.three)
setState(() {
_layout = Layout.two;
});
else
setState(() {
_layout = Layout.three;
});
},
icon: _layout == Layout.three
? SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
0,
context
.textTheme.bodyText1.color),
),
)
: SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
1,
context
.textTheme.bodyText1.color),
),
? snapshot.data.length == 0
? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(LineIcons.heartbeat_solid,
size: 80, color: Colors.grey[500]),
Padding(padding: EdgeInsets.symmetric(vertical: 10)),
Text(
'No episode collected yet',
style: TextStyle(color: Colors.grey[500]),
)
],
),
)
: NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification scrollInfo) {
if (scrollInfo.metrics.pixels ==
scrollInfo.metrics.maxScrollExtent &&
snapshot.data.length == _top) _loadMoreEpisode();
return true;
},
child: CustomScrollView(
key: PageStorageKey<String>('favorite'),
slivers: <Widget>[
SliverToBoxAdapter(
child: Container(
height: 40,
color: context.primaryColor,
child: Row(
children: <Widget>[
Material(
color: Colors.transparent,
child: PopupMenuButton<int>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(10))),
elevation: 1,
tooltip: 'Sort By',
child: Container(
height: 50,
padding: EdgeInsets.symmetric(
horizontal: 20),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('Sory by'),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 5),
),
Icon(
_sortBy == 0
? LineIcons
.cloud_download_alt_solid
: LineIcons.heartbeat_solid,
size: 18,
)
],
)),
itemBuilder: (context) => [
PopupMenuItem(
value: 0,
child: Text('Update Date'),
),
),
),
],
)),
PopupMenuItem(
value: 1,
child: Text('Like Date'),
)
],
onSelected: (value) {
if (value == 0)
setState(() => _sortBy = 0);
else if (value == 1)
setState(() => _sortBy = 1);
},
),
),
Spacer(),
Material(
color: Colors.transparent,
child: IconButton(
padding: EdgeInsets.zero,
onPressed: () {
if (_layout == Layout.three)
setState(() {
_layout = Layout.two;
});
else
setState(() {
_layout = Layout.three;
});
},
icon: _layout == Layout.three
? SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
0,
context.textTheme.bodyText1
.color),
),
)
: SizedBox(
height: 10,
width: 30,
child: CustomPaint(
painter: LayoutPainter(
1,
context.textTheme.bodyText1
.color),
),
),
),
),
],
)),
),
EpisodeGrid(
episodes: snapshot.data,
layout: _layout,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return _loadMore
? Container(
height: 2,
child: LinearProgressIndicator())
: Center();
},
childCount: 1,
),
),
],
),
EpisodeGrid(
episodes: snapshot.data,
layout: _layout,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return _loadMore
? Container(
height: 2, child: LinearProgressIndicator())
: Center();
},
childCount: 1,
),
),
],
),
)
: Center(child: CircularProgressIndicator());
)
: Center();
},
);
}
@ -903,10 +941,28 @@ class _MyDownloadState extends State<_MyDownload>
.toList()
.reversed
.toList();
return EpisodeGrid(
episodes: episodes,
layout: _layout,
);
return episodes.length == 0
? SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.only(top:100),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(LineIcons.download_solid,
size: 80, color: Colors.grey[500]),
Padding(padding: EdgeInsets.symmetric(vertical: 10)),
Text(
'No episode collected yet',
style: TextStyle(color: Colors.grey[500]),
)
],
),
),
)
: EpisodeGrid(
episodes: episodes,
layout: _layout,
);
},
),
],

View File

@ -1,7 +1,7 @@
name: tsacdop
description: An easy-use podacasts player.
version: 0.2.4
version: 0.3.0
environment:
sdk: ">=2.6.0 <3.0.0"