From 7c1305846333a96d7f59b201a75c7a5740e847ff Mon Sep 17 00:00:00 2001 From: Stonegate Date: Fri, 5 Feb 2021 00:08:16 +0800 Subject: [PATCH] Minor change. --- lib/home/home.dart | 234 ++++++++++++------------ lib/home/pocast_discovery.dart | 49 +++-- lib/home/search_podcast.dart | 24 ++- lib/widgets/custom_search_delegate.dart | 1 + 4 files changed, 160 insertions(+), 148 deletions(-) diff --git a/lib/home/home.dart b/lib/home/home.dart index 3c9c8d4..a4fba09 100644 --- a/lib/home/home.dart +++ b/lib/home/home.dart @@ -123,127 +123,131 @@ class _HomeState extends State with SingleTickerProviderStateMixin { Column( children: [ Expanded( - 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: [ - 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: + 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: [ + featureDiscoveryOverlay( + context, + featureId: addFeature, + tapTarget: 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, + title: s.featureDiscoverySearch, + backgroundColor: Colors.cyan[600], + buttonColor: Colors.cyan[500], description: - s.featureDiscoveryOMPLDes, - child: Padding( - padding: const EdgeInsets.only( - right: 5.0), - child: PopupMenu(), - )), - ], + 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(), + )), + ], + ), ), - ), - Import(), - ], - ), - ), - SliverToBoxAdapter( - child: SizedBox( - height: height, - width: width, - child: ScrollPodcasts(), - ), - ), - 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), - ) + Import(), ], ), ), - pinned: true, - ), - ]; - }, - body: TabBarView( - controller: _controller, - children: [ - NestedScrollViewInnerScrollPositionKeyWidget( - Key('tab0'), _RecentUpdate()), - NestedScrollViewInnerScrollPositionKeyWidget( - Key('tab1'), _MyFavorite()), - NestedScrollViewInnerScrollPositionKeyWidget( - Key('tab2'), _MyDownload()), - ], + SliverToBoxAdapter( + child: SizedBox( + height: height, + width: width, + child: ScrollPodcasts(), + ), + ), + 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), + ) + ], + ), + ), + pinned: true, + ), + ]; + }, + body: TabBarView( + controller: _controller, + children: [ + NestedScrollViewInnerScrollPositionKeyWidget( + Key('tab0'), _RecentUpdate()), + NestedScrollViewInnerScrollPositionKeyWidget( + Key('tab1'), _MyFavorite()), + NestedScrollViewInnerScrollPositionKeyWidget( + Key('tab2'), _MyDownload()), + ], + ), ), ), ), diff --git a/lib/home/pocast_discovery.dart b/lib/home/pocast_discovery.dart index 1797a95..4524a7f 100644 --- a/lib/home/pocast_discovery.dart +++ b/lib/home/pocast_discovery.dart @@ -120,28 +120,26 @@ class DiscoveryPageState extends State { builder: (context, snapshot) { if (snapshot.hasData && snapshot.data.isNotEmpty) { final history = snapshot.data; - return SizedBox( - child: Wrap( - direction: Axis.horizontal, - children: history - .map((e) => Padding( - padding: const EdgeInsets.fromLTRB(8, 2, 0, 0), - child: FlatButton.icon( - color: - Colors.accents[history.indexOf(e)].withAlpha(70), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(100.0), - ), - onPressed: () => widget.onTap(e), - label: Text(e), - icon: Icon( - Icons.search, - size: 20, - ), + return Wrap( + direction: Axis.horizontal, + children: history + .map((e) => Padding( + padding: const EdgeInsets.fromLTRB(8, 2, 0, 0), + child: FlatButton.icon( + color: + Colors.accents[history.indexOf(e)].withAlpha(70), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(100.0), ), - )) - .toList(), - ), + onPressed: () => widget.onTap(e), + label: Text(e), + icon: Icon( + Icons.search, + size: 20, + ), + ), + )) + .toList(), ); } return SizedBox( @@ -289,12 +287,7 @@ class DiscoveryPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ _historyList(), - Padding( - padding: EdgeInsets.fromLTRB(20, 10, 10, 4), - child: Text('Popular', - style: context.textTheme.headline6 - .copyWith(color: context.accentColor)), - ), + SizedBox(height: 8), SizedBox( height: 200, child: FutureBuilder>( @@ -344,7 +337,7 @@ class DiscoveryPageState extends State { widget.onTap(''); searchState.setGenre = e; }, - title: Text(e.name), + title: Text(e.name, style: context.textTheme.headline6), )) .toList(), ), diff --git a/lib/home/search_podcast.dart b/lib/home/search_podcast.dart index d5850d0..b39124f 100644 --- a/lib/home/search_podcast.dart +++ b/lib/home/search_podcast.dart @@ -85,9 +85,8 @@ class MyHomePageDelegate extends SearchDelegate { child: IconButton( tooltip: context.s.back, splashRadius: 20, - icon: AnimatedIcon( - icon: AnimatedIcons.menu_arrow, - progress: transitionAnimation, + icon: Icon( + _getIconData(Theme.of(context).platform) ), onPressed: () { close(context, 1); @@ -173,6 +172,21 @@ class MyHomePageDelegate extends SearchDelegate { } } } + + static IconData _getIconData(TargetPlatform platform) { + switch (platform) { + case TargetPlatform.android: + case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: + return Icons.arrow_back; + case TargetPlatform.iOS: + case TargetPlatform.macOS: + return Icons.arrow_back_ios; + } + assert(false); + return null; + } } class RssResult extends StatefulWidget { @@ -378,8 +392,8 @@ class __SearchPopupMenuState extends State<_SearchPopupMenu> { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), elevation: 1, icon: SizedBox( - height: 20, - width: 20, + height: 25, + width: 25, child: CircleAvatar( backgroundImage: _searchEngine == SearchEngine.podcastIndex ? AssetImage('assets/podcastindex_logo.png') diff --git a/lib/widgets/custom_search_delegate.dart b/lib/widgets/custom_search_delegate.dart index a251249..c7962a1 100644 --- a/lib/widgets/custom_search_delegate.dart +++ b/lib/widgets/custom_search_delegate.dart @@ -511,6 +511,7 @@ class _SearchPageState extends State<_SearchPage> { textTheme: theme.primaryTextTheme, brightness: theme.primaryColorBrightness, leading: widget.delegate.buildLeading(context), + elevation: 1, title: TextField( controller: widget.delegate._queryTextController, focusNode: focusNode,