From b2a2b53e668e7079217d9bdb628e4d659044a227 Mon Sep 17 00:00:00 2001 From: stonega Date: Sat, 6 Feb 2021 23:39:25 +0800 Subject: [PATCH] Minor change. --- lib/home/home.dart | 273 +++++++++++++++++------------------ lib/home/home_groups.dart | 3 +- lib/home/search_podcast.dart | 7 +- lib/widgets/episodegrid.dart | 3 +- 4 files changed, 141 insertions(+), 145 deletions(-) diff --git a/lib/home/home.dart b/lib/home/home.dart index 4ef7874..75866ae 100644 --- a/lib/home/home.dart +++ b/lib/home/home.dart @@ -100,143 +100,136 @@ class _HomeState extends State with SingleTickerProviderStateMixin { statusBarIconBrightness: Theme.of(context).accentColorBrightness, systemNavigationBarColor: Theme.of(context).primaryColor, ), - child: Scaffold( - key: _scaffoldKey, - body: WillPopScope( - onWillPop: () async { - if (_playerKey.currentState != null && - _playerKey.currentState.initSize > 100) { - _playerKey.currentState.backToMini(); - return false; - } else if (Platform.isAndroid) { - _androidAppRetain.invokeMethod('sendToBackground'); - return false; - } else { - return true; - } - }, - child: SafeArea( - bottom: false, - child: Stack( - children: [ - Column( - children: [ - Expanded( - child: ScrollConfiguration( - behavior: NoGrowBehavior(), - child: NestedScrollView( - innerScrollPositionKeyBuilder: () { - return Key('tab${_controller.index}'); - }, - pinnedHeaderSliverHeightBuilder: () => 50, - headerSliverBuilder: (context, innerBoxScrolled) { - return [ - SliverToBoxAdapter( - child: Column( + child: WillPopScope( + onWillPop: () async { + if (_playerKey.currentState != null && + _playerKey.currentState.initSize > 100) { + _playerKey.currentState.backToMini(); + return false; + } else if (Platform.isAndroid) { + _androidAppRetain.invokeMethod('sendToBackground'); + return false; + } else { + return true; + } + }, + child: Scaffold( + key: _scaffoldKey, + body: Stack( + children: [ + SafeArea( + bottom: false, + child: ScrollConfiguration( + behavior: NoGrowBehavior(), + child: NestedScrollView( + innerScrollPositionKeyBuilder: () { + return Key('tab${_controller.index}'); + }, + pinnedHeaderSliverHeightBuilder: () => 50, + headerSliverBuilder: (context, innerBoxScrolled) { + return [ + SliverToBoxAdapter( + child: Column( + children: [ + SizedBox( + height: 50.0, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - SizedBox( - height: 50.0, - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - featureDiscoveryOverlay( - context, - featureId: addFeature, - tapTarget: - Icon(Icons.add_circle_outline), - title: s.featureDiscoverySearch, - backgroundColor: Colors.cyan[600], - buttonColor: Colors.cyan[500], - description: - s.featureDiscoverySearchDes, - child: IconButton( - tooltip: s.add, - splashRadius: 20, - icon: Icon( - Icons.add_circle_outline), - onPressed: () async { - await showSearch( - context: context, - delegate: MyHomePageDelegate( - searchFieldLabel: - s.searchPodcast), - ); - }, - ), - ), - GestureDetector( - onTap: () => { - Theme.of(context).brightness == - Brightness.light - ? settings.setTheme = - ThemeMode.dark - : settings.setTheme = - ThemeMode.light - }, - child: Image( - image: Theme.of(context) - .brightness == - Brightness.light - ? AssetImage( - 'assets/text.png') - : AssetImage( - 'assets/text_light.png'), - height: 30, - ), - ), - featureDiscoveryOverlay(context, - featureId: menuFeature, - tapTarget: Icon(Icons.more_vert), - backgroundColor: Colors.cyan[500], - buttonColor: Colors.cyan[600], - title: s.featureDiscoveryOMPL, - description: - s.featureDiscoveryOMPLDes, - child: Padding( - padding: const EdgeInsets.only( - right: 5.0), - child: PopupMenu(), - )), - ], + featureDiscoveryOverlay( + context, + featureId: addFeature, + tapTarget: Icon(Icons.add_circle_outline), + title: s.featureDiscoverySearch, + backgroundColor: Colors.cyan[600], + buttonColor: Colors.cyan[500], + description: s.featureDiscoverySearchDes, + child: IconButton( + tooltip: s.add, + splashRadius: 20, + icon: Icon(Icons.add_circle_outline), + onPressed: () async { + await showSearch( + context: context, + delegate: MyHomePageDelegate( + searchFieldLabel: + s.searchPodcast), + ); + }, ), ), - Import(), + GestureDetector( + onTap: () => { + Theme.of(context).brightness == + Brightness.light + ? settings.setTheme = ThemeMode.dark + : settings.setTheme = + ThemeMode.light + }, + child: Image( + image: Theme.of(context).brightness == + Brightness.light + ? AssetImage('assets/text.png') + : AssetImage( + 'assets/text_light.png'), + height: 30, + ), + ), + featureDiscoveryOverlay(context, + featureId: menuFeature, + tapTarget: Icon(Icons.more_vert), + backgroundColor: Colors.cyan[500], + buttonColor: Colors.cyan[600], + title: s.featureDiscoveryOMPL, + description: s.featureDiscoveryOMPLDes, + child: Padding( + padding: + const EdgeInsets.only(right: 5.0), + child: PopupMenu(), + )), ], ), ), - SliverToBoxAdapter( - child: SizedBox( - height: height, - width: context.width, - child: ScrollPodcasts(), + Import(), + ], + ), + ), + SliverToBoxAdapter( + child: SizedBox( + height: height, + width: context.width, + child: ScrollPodcasts(), + ), + ), + SliverPersistentHeader( + delegate: _SliverAppBarDelegate( + TabBar( + indicator: _getIndicator(context), + isScrollable: true, + indicatorSize: TabBarIndicatorSize.tab, + controller: _controller, + tabs: [ + Tab( + child: Text(s.homeTabMenuRecent), ), - ), - SliverPersistentHeader( - delegate: _SliverAppBarDelegate( - TabBar( - indicator: _getIndicator(context), - isScrollable: true, - indicatorSize: TabBarIndicatorSize.tab, - controller: _controller, - tabs: [ - Tab( - child: Text(s.homeTabMenuRecent), - ), - Tab( - child: Text(s.homeTabMenuFavotite), - ), - Tab( - child: Text(s.download), - ) - ], - ), + Tab( + child: Text(s.homeTabMenuFavotite), ), - pinned: true, - ), - ]; - }, - body: TabBarView( + Tab( + child: Text(s.download), + ) + ], + ), + ), + pinned: true, + ), + ]; + }, + body: Column( + children: [ + Expanded( + child: TabBarView( controller: _controller, children: [ NestedScrollViewInnerScrollPositionKeyWidget( @@ -248,23 +241,25 @@ class _HomeState extends State with SingleTickerProviderStateMixin { ], ), ), - ), + Selector( + selector: (_, audio) => + audio?.playerRunning ?? false, + builder: (_, data, __) { + return Padding( + padding: + EdgeInsets.only(bottom: data ? 60.0 : 0), + ); + }), + ], ), - Selector( - selector: (_, audio) => audio?.playerRunning ?? false, - builder: (_, data, __) { - return Padding( - padding: EdgeInsets.only(bottom: data ? 60.0 : 0), - ); - }), - ], + ), ), + ), Container(child: PlayerWidget(playerKey: _playerKey)), ], ), ), ), - ), ); } } diff --git a/lib/home/home_groups.dart b/lib/home/home_groups.dart index 7304d8c..5b09092 100644 --- a/lib/home/home_groups.dart +++ b/lib/home/home_groups.dart @@ -763,7 +763,8 @@ class ShowEpisode extends StatelessWidget { color: context.accentColor, ), onPressed: () { - if (data.item1 != episodes[index]) { + if (data.item1 != episodes[index] || + !data.item3) { audio.episodeLoad(episodes[index]); } }), diff --git a/lib/home/search_podcast.dart b/lib/home/search_podcast.dart index ddabbc9..464bcea 100644 --- a/lib/home/search_podcast.dart +++ b/lib/home/search_podcast.dart @@ -85,9 +85,7 @@ class MyHomePageDelegate extends SearchDelegate { child: IconButton( tooltip: context.s.back, splashRadius: 20, - icon: Icon( - _getIconData(Theme.of(context).platform) - ), + icon: Icon(_getIconData(Theme.of(context).platform)), onPressed: () { close(context, 1); }, @@ -173,7 +171,7 @@ class MyHomePageDelegate extends SearchDelegate { } } - static IconData _getIconData(TargetPlatform platform) { + static IconData _getIconData(TargetPlatform platform) { switch (platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: @@ -1322,6 +1320,7 @@ class PodcastAvatar extends StatelessWidget { fit: BoxFit.fitWidth, alignment: Alignment.center, imageUrl: podcast.image, + placeholderFadeInDuration: Duration.zero, progressIndicatorBuilder: (context, url, downloadProgress) => Container( height: 50, diff --git a/lib/widgets/episodegrid.dart b/lib/widgets/episodegrid.dart index b678b90..e8abb26 100644 --- a/lib/widgets/episodegrid.dart +++ b/lib/widgets/episodegrid.dart @@ -665,7 +665,8 @@ class EpisodeGrid extends StatelessWidget { color: Theme.of(context).accentColor, ), onPressed: () { - if (data.item1 != episodes[index]) { + if (data.item1 != episodes[index] || + !data.item4) { audio.episodeLoad(episodes[index]); } }),