Minor change.

This commit is contained in:
stonega 2021-02-06 23:39:25 +08:00
parent db5d038e62
commit b2a2b53e66
4 changed files with 141 additions and 145 deletions

View File

@ -100,143 +100,136 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
statusBarIconBrightness: Theme.of(context).accentColorBrightness, statusBarIconBrightness: Theme.of(context).accentColorBrightness,
systemNavigationBarColor: Theme.of(context).primaryColor, systemNavigationBarColor: Theme.of(context).primaryColor,
), ),
child: Scaffold( child: WillPopScope(
key: _scaffoldKey, onWillPop: () async {
body: WillPopScope( if (_playerKey.currentState != null &&
onWillPop: () async { _playerKey.currentState.initSize > 100) {
if (_playerKey.currentState != null && _playerKey.currentState.backToMini();
_playerKey.currentState.initSize > 100) { return false;
_playerKey.currentState.backToMini(); } else if (Platform.isAndroid) {
return false; _androidAppRetain.invokeMethod('sendToBackground');
} else if (Platform.isAndroid) { return false;
_androidAppRetain.invokeMethod('sendToBackground'); } else {
return false; return true;
} else { }
return true; },
} child: Scaffold(
}, key: _scaffoldKey,
child: SafeArea( body: Stack(
bottom: false, children: <Widget>[
child: Stack( SafeArea(
children: <Widget>[ bottom: false,
Column( child: ScrollConfiguration(
children: <Widget>[ behavior: NoGrowBehavior(),
Expanded( child: NestedScrollView(
child: ScrollConfiguration( innerScrollPositionKeyBuilder: () {
behavior: NoGrowBehavior(), return Key('tab${_controller.index}');
child: NestedScrollView( },
innerScrollPositionKeyBuilder: () { pinnedHeaderSliverHeightBuilder: () => 50,
return Key('tab${_controller.index}'); headerSliverBuilder: (context, innerBoxScrolled) {
}, return <Widget>[
pinnedHeaderSliverHeightBuilder: () => 50, SliverToBoxAdapter(
headerSliverBuilder: (context, innerBoxScrolled) { child: Column(
return <Widget>[ children: <Widget>[
SliverToBoxAdapter( SizedBox(
child: Column( height: 50.0,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
SizedBox( featureDiscoveryOverlay(
height: 50.0, context,
child: Row( featureId: addFeature,
mainAxisAlignment: tapTarget: Icon(Icons.add_circle_outline),
MainAxisAlignment.spaceBetween, title: s.featureDiscoverySearch,
children: <Widget>[ backgroundColor: Colors.cyan[600],
featureDiscoveryOverlay( buttonColor: Colors.cyan[500],
context, description: s.featureDiscoverySearchDes,
featureId: addFeature, child: IconButton(
tapTarget: tooltip: s.add,
Icon(Icons.add_circle_outline), splashRadius: 20,
title: s.featureDiscoverySearch, icon: Icon(Icons.add_circle_outline),
backgroundColor: Colors.cyan[600], onPressed: () async {
buttonColor: Colors.cyan[500], await showSearch<int>(
description: context: context,
s.featureDiscoverySearchDes, delegate: MyHomePageDelegate(
child: IconButton( searchFieldLabel:
tooltip: s.add, s.searchPodcast),
splashRadius: 20, );
icon: Icon( },
Icons.add_circle_outline),
onPressed: () async {
await showSearch<int>(
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(), 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( Import(),
child: SizedBox( ],
height: height, ),
width: context.width, ),
child: ScrollPodcasts(), 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: <Widget>[
Tab(
child: Text(s.homeTabMenuRecent),
), ),
), Tab(
SliverPersistentHeader( child: Text(s.homeTabMenuFavotite),
delegate: _SliverAppBarDelegate(
TabBar(
indicator: _getIndicator(context),
isScrollable: true,
indicatorSize: TabBarIndicatorSize.tab,
controller: _controller,
tabs: <Widget>[
Tab(
child: Text(s.homeTabMenuRecent),
),
Tab(
child: Text(s.homeTabMenuFavotite),
),
Tab(
child: Text(s.download),
)
],
),
), ),
pinned: true, Tab(
), child: Text(s.download),
]; )
}, ],
body: TabBarView( ),
),
pinned: true,
),
];
},
body: Column(
children: [
Expanded(
child: TabBarView(
controller: _controller, controller: _controller,
children: <Widget>[ children: <Widget>[
NestedScrollViewInnerScrollPositionKeyWidget( NestedScrollViewInnerScrollPositionKeyWidget(
@ -248,23 +241,25 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
], ],
), ),
), ),
), Selector<AudioPlayerNotifier, bool>(
selector: (_, audio) =>
audio?.playerRunning ?? false,
builder: (_, data, __) {
return Padding(
padding:
EdgeInsets.only(bottom: data ? 60.0 : 0),
);
}),
],
), ),
Selector<AudioPlayerNotifier, bool>( ),
selector: (_, audio) => audio?.playerRunning ?? false,
builder: (_, data, __) {
return Padding(
padding: EdgeInsets.only(bottom: data ? 60.0 : 0),
);
}),
],
), ),
),
Container(child: PlayerWidget(playerKey: _playerKey)), Container(child: PlayerWidget(playerKey: _playerKey)),
], ],
), ),
), ),
), ),
),
); );
} }
} }

View File

@ -763,7 +763,8 @@ class ShowEpisode extends StatelessWidget {
color: context.accentColor, color: context.accentColor,
), ),
onPressed: () { onPressed: () {
if (data.item1 != episodes[index]) { if (data.item1 != episodes[index] ||
!data.item3) {
audio.episodeLoad(episodes[index]); audio.episodeLoad(episodes[index]);
} }
}), }),

View File

@ -85,9 +85,7 @@ class MyHomePageDelegate extends SearchDelegate<int> {
child: IconButton( child: IconButton(
tooltip: context.s.back, tooltip: context.s.back,
splashRadius: 20, splashRadius: 20,
icon: Icon( icon: Icon(_getIconData(Theme.of(context).platform)),
_getIconData(Theme.of(context).platform)
),
onPressed: () { onPressed: () {
close(context, 1); close(context, 1);
}, },
@ -173,7 +171,7 @@ class MyHomePageDelegate extends SearchDelegate<int> {
} }
} }
static IconData _getIconData(TargetPlatform platform) { static IconData _getIconData(TargetPlatform platform) {
switch (platform) { switch (platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
@ -1322,6 +1320,7 @@ class PodcastAvatar extends StatelessWidget {
fit: BoxFit.fitWidth, fit: BoxFit.fitWidth,
alignment: Alignment.center, alignment: Alignment.center,
imageUrl: podcast.image, imageUrl: podcast.image,
placeholderFadeInDuration: Duration.zero,
progressIndicatorBuilder: (context, url, downloadProgress) => progressIndicatorBuilder: (context, url, downloadProgress) =>
Container( Container(
height: 50, height: 50,

View File

@ -665,7 +665,8 @@ class EpisodeGrid extends StatelessWidget {
color: Theme.of(context).accentColor, color: Theme.of(context).accentColor,
), ),
onPressed: () { onPressed: () {
if (data.item1 != episodes[index]) { if (data.item1 != episodes[index] ||
!data.item4) {
audio.episodeLoad(episodes[index]); audio.episodeLoad(episodes[index]);
} }
}), }),