From bcaab84b8f5424666dbdc3928cee3e431ec93950 Mon Sep 17 00:00:00 2001 From: Stonegate Date: Thu, 7 Jan 2021 00:29:24 +0800 Subject: [PATCH] Support open podcasts page insteam of group page. --- lib/home/home_groups.dart | 27 ++++++++++++++++----------- lib/podcasts/podcast_manage.dart | 19 +++++++++++++------ lib/podcasts/podcastlist.dart | 21 +++++++++++++++++---- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/lib/home/home_groups.dart b/lib/home/home_groups.dart index 44c449b..04f3dcf 100644 --- a/lib/home/home_groups.dart +++ b/lib/home/home_groups.dart @@ -10,6 +10,7 @@ import 'package:focused_menu/modals.dart'; import 'package:line_icons/line_icons.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; +import 'package:tsacdop/state/setting_state.dart'; import 'package:tuple/tuple.dart' as tuple; import '../episodes/episode_detail.dart'; @@ -30,7 +31,6 @@ import '../util/hide_player_route.dart'; import '../util/pageroute.dart'; import '../widgets/custom_widget.dart'; import '../widgets/general_dialog.dart'; -import 'home.dart'; class ScrollPodcasts extends StatefulWidget { @override @@ -115,11 +115,11 @@ class _ScrollPodcastsState extends State var groups = data.item1; var import = data.item2; return groups.isEmpty - ? Container( + ? SizedBox( height: (width - 20) / 3 + 140, ) : groups[_groupIndex].podcastList.length == 0 - ? Container( + ? SizedBox( height: (width - 20) / 3 + 140, child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -184,7 +184,12 @@ class _ScrollPodcastsState extends State Navigator.push( context, SlideLeftRoute( - page: PodcastManage()), + page: context + .read< + SettingState>() + .openAllPodcastDefalt + ? PodcastList() + : PodcastManage()), ); } }, @@ -344,7 +349,12 @@ class _ScrollPodcastsState extends State Navigator.push( context, SlideLeftRoute( - page: PodcastManage()), + page: context + .read< + SettingState>() + .openAllPodcastDefalt + ? PodcastList() + : PodcastManage()), ); } }, @@ -455,12 +465,7 @@ class _ScrollPodcastsState extends State hide: true), duration: Duration( milliseconds: 300), - ) - // SlideLeftRoute( - // page: PodcastDetail( - // podcastLocal: podcastLocal, - // )), - ); + )); }, child: PodcastPreview( podcastLocal: podcastLocal, diff --git a/lib/podcasts/podcast_manage.dart b/lib/podcasts/podcast_manage.dart index 7d5ef0b..6893462 100644 --- a/lib/podcasts/podcast_manage.dart +++ b/lib/podcasts/podcast_manage.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:line_icons/line_icons.dart'; import 'package:provider/provider.dart'; +import 'package:tsacdop/state/setting_state.dart'; import '../state/podcast_group.dart'; import '../util/extension_helper.dart'; @@ -189,12 +190,18 @@ class _PodcastManageState extends State AddGroup()), icon: Icon(Icons.add_circle_outline)), ), - IconButton( - splashRadius: 20, - onPressed: () => - Navigator.push(context, ScaleRoute(page: PodcastList())), - icon: Icon(Icons.all_out)), - // _OrderMenu(), + Selector( + selector: (_, setting) => setting.openAllPodcastDefalt, + builder: (_, data, __) { + return !data + ? IconButton( + splashRadius: 20, + onPressed: () => Navigator.push( + context, ScaleRoute(page: PodcastList())), + icon: Icon(Icons.all_out)) + : Center(); + }) + // _OrderMenu(), ], ), body: WillPopScope( diff --git a/lib/podcasts/podcastlist.dart b/lib/podcasts/podcastlist.dart index a06c4f4..cf8bda0 100644 --- a/lib/podcasts/podcastlist.dart +++ b/lib/podcasts/podcastlist.dart @@ -7,6 +7,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:provider/provider.dart'; +import 'package:tsacdop/class/settingstate.dart'; import '../local_storage/sqflite_localpodcast.dart'; import '../state/podcast_group.dart'; @@ -16,6 +17,7 @@ import '../util/pageroute.dart'; import '../widgets/custom_widget.dart'; import '../widgets/general_dialog.dart'; import 'podcast_detail.dart'; +import 'podcast_manage.dart'; import 'podcast_settings.dart'; class AboutPodcast extends StatefulWidget { @@ -51,8 +53,7 @@ class _AboutPodcastState extends State { var _groupList = Provider.of(context, listen: false); final s = context.s; return AlertDialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0))), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)), titlePadding: EdgeInsets.only( top: 20, left: 20, right: context.width / 3, bottom: 20), actions: [ @@ -117,7 +118,19 @@ class _PodcastListState extends State { appBar: AppBar( title: Text(context.s.podcast(2)), leading: CustomBackButton(), - centerTitle: true, + actions: [ + Selector( + selector: (_, setting) => setting.openAllPodcastDefalt, + builder: (_, data, __) { + return data + ? IconButton( + splashRadius: 20, + icon: Icon(Icons.all_out), + onPressed: () => Navigator.push( + context, ScaleRoute(page: PodcastManage()))) + : Center(); + }) + ], ), body: SafeArea( child: Container( @@ -142,7 +155,7 @@ class _PodcastListState extends State { onTap: () { Navigator.push( context, - ScaleRoute( + SlideLeftRoute( page: PodcastDetail( podcastLocal: snapshot.data[index], )),