diff --git a/lib/playlists/playlist_home.dart b/lib/playlists/playlist_home.dart index c62eb13..055dc74 100644 --- a/lib/playlists/playlist_home.dart +++ b/lib/playlists/playlist_home.dart @@ -525,7 +525,7 @@ class __HistoryState extends State<_History> { onPressed: () async { audio.delFromPlaylist(episode!); Fluttertoast.showToast( - msg: s!.toastRemovePlaylist, + msg: s.toastRemovePlaylist, gravity: ToastGravity.BOTTOM, ); }) @@ -534,7 +534,7 @@ class __HistoryState extends State<_History> { onPressed: () async { audio.addToPlaylist(episode!); Fluttertoast.showToast( - msg: s!.toastAddPlaylist, + msg: s.toastAddPlaylist, gravity: ToastGravity.BOTTOM, ); }); @@ -724,7 +724,7 @@ class __PlaylistsState extends State<_Playlists> { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - s!.queue, + s.queue, style: context.textTheme.headline6, ), Text( @@ -743,14 +743,13 @@ class __PlaylistsState extends State<_Playlists> { children: [ Text(s.play.toUpperCase(), style: TextStyle( - color: - Theme.of(context).accentColor, + color: context.accentColor, fontSize: 15, fontWeight: FontWeight.bold, )), Icon( Icons.play_arrow, - color: Theme.of(context).accentColor, + color: context.accentColor, ), ], ), @@ -798,7 +797,7 @@ class __PlaylistsState extends State<_Playlists> { ), title: Text(data[index].name!), subtitle: Text( - '${data[index].length} ${s!.episode(data[index].length).toLowerCase()}'), + '${data[index].length} ${s.episode(data[index].length).toLowerCase()}'), trailing: TextButton( style: TextButton.styleFrom( primary: context.accentColor, @@ -808,13 +807,13 @@ class __PlaylistsState extends State<_Playlists> { children: [ Text(s.play.toUpperCase(), style: TextStyle( - color: Theme.of(context).accentColor, + color: context.accentColor, fontSize: 15, fontWeight: FontWeight.bold, )), Icon( Icons.play_arrow, - color: Theme.of(context).accentColor, + color: context.accentColor, ), ], ), diff --git a/lib/playlists/playlist_page.dart b/lib/playlists/playlist_page.dart index a85ec83..3e16345 100644 --- a/lib/playlists/playlist_page.dart +++ b/lib/playlists/playlist_page.dart @@ -43,9 +43,9 @@ class _PlaylistDetailState extends State { ), title: Text(_selectedEpisodes.isEmpty ? widget.playlist.isQueue - ? s!.queue + ? s.queue : widget.playlist.name! - : s!.selected(_selectedEpisodes.length)), + : s.selected(_selectedEpisodes.length)), actions: [ if (_selectedEpisodes.isNotEmpty) IconButton( @@ -86,40 +86,40 @@ class _PlaylistDetailState extends State { ], ), body: Selector>( - selector: (_, audio) => audio.playlists, - builder: (_, data, __) { - final playlist = data.firstWhereOrNull( - (e) => e == widget.playlist, - ); - final episodes = playlist?.episodes ?? []; - return ReorderableListView( - onReorder: (oldIndex, newIndex) { - if (widget.playlist.isQueue) { - context - .read() - .reorderPlaylist(oldIndex, newIndex); - setState(() {}); - } else { - context - .read() - .reorderEpisodesInPlaylist(widget.playlist, - oldIndex: oldIndex, newIndex: newIndex); - setState(() {}); - } - }, - scrollDirection: Axis.vertical, - children: episodes.map((episode) { - return _PlaylistItem(episode, - key: ValueKey(episode!.enclosureUrl), - onSelect: (episode) { - _selectedEpisodes.add(episode); - setState(() {}); - }, onRemove: (episode) { - _selectedEpisodes.remove(episode); - setState(() {}); - }, reset: _resetSelected); - }).toList()); - }), + selector: (_, audio) => audio.playlists, + builder: (_, data, __) { + final playlist = data.firstWhereOrNull( + (e) => e == widget.playlist, + ); + final episodes = playlist?.episodes ?? []; + return ReorderableListView( + onReorder: (oldIndex, newIndex) { + if (widget.playlist.isQueue) { + context + .read() + .reorderPlaylist(oldIndex, newIndex); + setState(() {}); + } else { + context.read().reorderEpisodesInPlaylist( + widget.playlist, + oldIndex: oldIndex, + newIndex: newIndex); + setState(() {}); + } + }, + scrollDirection: Axis.vertical, + children: episodes.map((episode) { + return _PlaylistItem(episode, + key: ValueKey(episode!.enclosureUrl), onSelect: (episode) { + _selectedEpisodes.add(episode); + setState(() {}); + }, onRemove: (episode) { + _selectedEpisodes.remove(episode); + setState(() {}); + }, reset: _resetSelected); + }).toList()); + }, + ), ); } } @@ -269,7 +269,7 @@ class __PlaylistItemState extends State<_PlaylistItem> _episodeTag( episode.duration == 0 ? '' - : s!.minsCount(episode.duration! ~/ 60), + : s.minsCount(episode.duration! ~/ 60), Colors.cyan[300]), if (episode.enclosureLength != null) _episodeTag( @@ -338,7 +338,7 @@ class __PlaylistSettingState extends State<_PlaylistSetting> { child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - FlatButton( + TextButton( onPressed: () => setState(() { _clearConfirm = false; }), @@ -381,7 +381,7 @@ class __PlaylistSettingState extends State<_PlaylistSetting> { child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - FlatButton( + TextButton( onPressed: () => setState(() { _removeConfirm = false; }), @@ -407,9 +407,9 @@ class __PlaylistSettingState extends State<_PlaylistSetting> { child: Row( children: [ Icon(Icons.info_outline, - size: 16, color: context.textColor!.withAlpha(90)), + size: 16, color: context.textColor.withAlpha(90)), Text(s.defaultQueueReminder, - style: TextStyle(color: context.textColor!.withAlpha(90))), + style: TextStyle(color: context.textColor.withAlpha(90))), ], ), ) diff --git a/lib/podcasts/custom_tabview.dart b/lib/podcasts/custom_tabview.dart index 98dc615..307c659 100644 --- a/lib/podcasts/custom_tabview.dart +++ b/lib/podcasts/custom_tabview.dart @@ -56,7 +56,7 @@ class _CustomTabsState extends State _currentPosition = widget.itemCount - 1; _currentPosition = _currentPosition! < 0 ? 0 : _currentPosition; if (widget.onPositionChange is ValueChanged) { - WidgetsBinding.instance!.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { widget.onPositionChange!(_currentPosition); } diff --git a/lib/podcasts/podcast_detail.dart b/lib/podcasts/podcast_detail.dart index 4b265ec..49daadb 100644 --- a/lib/podcasts/podcast_detail.dart +++ b/lib/podcasts/podcast_detail.dart @@ -457,14 +457,16 @@ class _PodcastDetailState extends State { borderRadius: BorderRadius.circular(5), border: Border.all( width: 2, - color: context.textColor!.withOpacity(0.2))), + color: context.textColor.withOpacity(0.2))), child: _query == '' ? Row( children: [ - Text(s.search, - style: TextStyle( - color: context.textColor! - .withOpacity(0.4))), + Text( + s.search, + style: TextStyle( + color: context.textColor.withOpacity(0.4), + ), + ), Spacer() ], ) @@ -732,7 +734,6 @@ class _PodcastDetailState extends State { physics: const AlwaysScrollableScrollPhysics(), slivers: [ SliverAppBar( - brightness: Brightness.dark, actions: [ IconButton( icon: Icon(Icons.more_vert), diff --git a/lib/podcasts/podcast_manage.dart b/lib/podcasts/podcast_manage.dart index a9146fc..4894f15 100644 --- a/lib/podcasts/podcast_manage.dart +++ b/lib/podcasts/podcast_manage.dart @@ -1,7 +1,6 @@ import 'dart:math' as math; import 'package:feature_discovery/feature_discovery.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -65,7 +64,7 @@ class _PodcastManageState extends State _controller.stop(); } }); - WidgetsBinding.instance!.addPostFrameCallback((_) { + WidgetsBinding.instance.addPostFrameCallback((_) { FeatureDiscovery.discoverFeatures(context, const {addGroupFeature, configureGroup, configurePodcast}); }); @@ -91,7 +90,7 @@ class _PodcastManageState extends State context, featureId: configureGroup, tapTarget: Icon(Icons.menu), - title: s!.featureDiscoveryEditGroup, + title: s.featureDiscoveryEditGroup, backgroundColor: Colors.cyan[600], description: s.featureDiscoveryEditGroupDes, buttonColor: Colors.cyan[500], @@ -126,9 +125,7 @@ class _PodcastManageState extends State width: 50, height: 50, decoration: BoxDecoration( - color: _fraction! > 0.5 - ? Colors.red - : Theme.of(context).accentColor, + color: _fraction! > 0.5 ? Colors.red : context.accentColor, shape: BoxShape.circle, boxShadow: [ BoxShadow( @@ -159,10 +156,9 @@ class _PodcastManageState extends State final s = context.s; return AnnotatedRegion( value: SystemUiOverlayStyle( - statusBarIconBrightness: Theme.of(context).accentColorBrightness, - systemNavigationBarColor: Theme.of(context).primaryColor, - systemNavigationBarIconBrightness: - Theme.of(context).accentColorBrightness, + statusBarIconBrightness: context.brightness, + systemNavigationBarColor: context.primaryColor, + systemNavigationBarIconBrightness: context.iconBrightness, // statusBarColor: Theme.of(context).primaryColor, ), child: Scaffold( @@ -530,8 +526,8 @@ class _AddGroupState extends State { Navigator.of(context).pop(); } }, - child: Text(s.confirm, - style: TextStyle(color: Theme.of(context).accentColor)), + child: + Text(s.confirm, style: TextStyle(color: context.accentColor)), ) ], title: SizedBox(width: context.width - 160, child: Text(s.newGroup)), diff --git a/lib/settings/data_backup.dart b/lib/settings/data_backup.dart index 49a9a37..42cd400 100644 --- a/lib/settings/data_backup.dart +++ b/lib/settings/data_backup.dart @@ -121,7 +121,7 @@ class _DataBackupState extends State { return; } Fluttertoast.showToast( - msg: s!.toastReadFile, + msg: s.toastReadFile, gravity: ToastGravity.BOTTOM, ); final filePath = filePickResult.files.first.path!; diff --git a/lib/settings/downloads_manage.dart b/lib/settings/downloads_manage.dart index 07e4815..e5f225b 100644 --- a/lib/settings/downloads_manage.dart +++ b/lib/settings/downloads_manage.dart @@ -84,9 +84,9 @@ class _DownloadsManageState extends State { var date = DateTime.fromMillisecondsSinceEpoch(downloadDate); var diffrence = DateTime.now().toUtc().difference(date); if (diffrence.inHours < 24) { - return s!.hoursAgo(diffrence.inHours); + return s.hoursAgo(diffrence.inHours); } else if (diffrence.inDays < 7) { - return s!.daysAgo(diffrence.inDays); + return s.daysAgo(diffrence.inDays); } else { return DateFormat.yMMMd().format( DateTime.fromMillisecondsSinceEpoch(pubDate!, isUtc: true).toLocal()); diff --git a/lib/settings/history.dart b/lib/settings/history.dart index 3cd553d..a87c179 100644 --- a/lib/settings/history.dart +++ b/lib/settings/history.dart @@ -123,10 +123,9 @@ class _PlayedHistoryState extends State final s = context.s; return AnnotatedRegion( value: SystemUiOverlayStyle( - statusBarIconBrightness: Theme.of(context).accentColorBrightness, + statusBarIconBrightness: context.brightness, systemNavigationBarColor: Theme.of(context).primaryColor, - systemNavigationBarIconBrightness: - Theme.of(context).accentColorBrightness, + systemNavigationBarIconBrightness: context.iconBrightness, ), child: Scaffold( backgroundColor: context.primaryColor, @@ -147,7 +146,7 @@ class _PlayedHistoryState extends State return FlexibleSpaceBar( title: top < 70 + MediaQuery.of(context).padding.top ? Text( - s!.settingsHistory, + s.settingsHistory, ) : Center(), background: Padding( @@ -237,7 +236,7 @@ class _PlayedHistoryState extends State .data![index] .playdate!), style: TextStyle( - color: context.textColor! + color: context.textColor .withOpacity(0.8), fontSize: 15, fontStyle: @@ -285,7 +284,7 @@ class _PlayedHistoryState extends State padding: EdgeInsets.all(2), child: Text( seconds == 0 && seekValue == 1 - ? s!.mark + ? s.mark : seconds!.toInt().toTime, style: TextStyle( color: Colors.white), @@ -334,7 +333,7 @@ class _PlayedHistoryState extends State DateFormat.yMd().add_jm().format( snapshot.data![index].subDate), style: TextStyle( - color: context.textColor! + color: context.textColor .withOpacity(0.8), fontSize: 15, fontStyle: FontStyle.italic), @@ -348,7 +347,7 @@ class _PlayedHistoryState extends State snapshot.data![index].subDate) .inDays)) : Text( - s!.removedAt(DateFormat.yMd() + s.removedAt(DateFormat.yMd() .add_jm() .format(snapshot .data![index].delDate)), diff --git a/lib/settings/layouts.dart b/lib/settings/layouts.dart index dd1273c..91d4ad5 100644 --- a/lib/settings/layouts.dart +++ b/lib/settings/layouts.dart @@ -65,11 +65,11 @@ class _LayoutSettingState extends State { final s = context.s; switch (mode) { case PlayerHeight.short: - return s!.playerHeightShort; + return s.playerHeightShort; case PlayerHeight.mid: - return s!.playerHeightMed; + return s.playerHeightMed; case PlayerHeight.tall: - return s!.playerHeightTall; + return s.playerHeightTall; default: return ''; } diff --git a/lib/settings/play_setting.dart b/lib/settings/play_setting.dart index afb5ded..65461b7 100644 --- a/lib/settings/play_setting.dart +++ b/lib/settings/play_setting.dart @@ -1,5 +1,3 @@ -import 'dart:ui'; - import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -43,11 +41,11 @@ class _PlaySettingState extends State { String _volumeEffect(BuildContext context, int? i) { final s = context.s; if (i == 2000) { - return s!.playerHeightShort; + return s.playerHeightShort; } else if (i == 3000) { - return s!.playerHeightMed; + return s.playerHeightMed; } - return s!.playerHeightTall; + return s.playerHeightTall; } Future _getMarkListenedSkip() async { @@ -142,7 +140,7 @@ class _PlaySettingState extends State { var startTime = data.item1!; final timeOfDay = await showCustomTimePicker( context: context, - cancelText: s!.cancel, + cancelText: s.cancel, confirmText: s.confirm, helpText: '', initialTime: TimeOfDay( @@ -227,10 +225,9 @@ class _PlaySettingState extends State { final s = context.s; return AnnotatedRegion( value: SystemUiOverlayStyle( - statusBarIconBrightness: Theme.of(context).accentColorBrightness, - systemNavigationBarColor: Theme.of(context).primaryColor, - systemNavigationBarIconBrightness: - Theme.of(context).accentColorBrightness, + statusBarIconBrightness: context.brightness, + systemNavigationBarColor: context.primaryColor, + systemNavigationBarIconBrightness: context.iconBrightness, ), child: Scaffold( appBar: AppBar( @@ -264,11 +261,13 @@ class _PlaySettingState extends State { height: 30.0, padding: EdgeInsets.symmetric(horizontal: 70), alignment: Alignment.centerLeft, - child: Text(s.homeMenuPlaylist, - style: Theme.of(context) - .textTheme - .bodyText1! - .copyWith(color: Theme.of(context).accentColor)), + child: Text( + s.homeMenuPlaylist, + style: Theme.of(context) + .textTheme + .bodyText1! + .copyWith(color: context.accentColor), + ), ), Selector( selector: (_, settings) => settings.autoPlay, @@ -389,9 +388,11 @@ class _PlaySettingState extends State { height: 30.0, padding: EdgeInsets.symmetric(horizontal: 70), alignment: Alignment.centerLeft, - child: Text(s.sleepTimer, - style: context.textTheme.bodyText1! - .copyWith(color: Theme.of(context).accentColor)), + child: Text( + s.sleepTimer, + style: context.textTheme.bodyText1! + .copyWith(color: context.accentColor), + ), ), ListView( physics: const BouncingScrollPhysics(), @@ -494,7 +495,7 @@ class __NotificationLayoutState extends State<_NotificationLayout> { SizedBox(height: 8), Text(des, style: TextStyle( - fontSize: 12, color: context.textColor!.withOpacity(0.5)), + fontSize: 12, color: context.textColor.withOpacity(0.5)), textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.clip), @@ -526,8 +527,8 @@ class __NotificationLayoutState extends State<_NotificationLayout> { mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ - _notificationIcon(Icon(Icons.pause_circle_filled), - '${s!.play}| ${s.pause}'), + _notificationIcon( + Icon(Icons.pause_circle_filled), '${s.play}| ${s.pause}'), _notificationIcon(Icon(Icons.fast_forward), s.fastForward), _notificationIcon(Icon(Icons.skip_next), s.skipToNext), _notificationIcon(Icon(Icons.close), s.stop), @@ -539,7 +540,7 @@ class __NotificationLayoutState extends State<_NotificationLayout> { crossAxisAlignment: CrossAxisAlignment.start, children: [ _notificationIcon(Icon(Icons.pause_circle_filled), - '${s!.play}| ${s.pause}'), + '${s.play}| ${s.pause}'), _notificationIcon( Icon(Icons.fast_rewind), s.fastRewind), _notificationIcon(Icon(Icons.skip_next), s.skipToNext), @@ -549,7 +550,7 @@ class __NotificationLayoutState extends State<_NotificationLayout> { mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ - _notificationIcon(Icon(Icons.fast_rewind), s!.fastRewind), + _notificationIcon(Icon(Icons.fast_rewind), s.fastRewind), _notificationIcon(Icon(Icons.pause_circle_filled), '${s.play}| ${s.pause}'), _notificationIcon( @@ -612,38 +613,42 @@ class __SpeedListState extends State<_SpeedList> { children: [ Text(s.settingsSpeedsDes), FutureBuilder>( - future: _getSpeedList(), - initialData: [], - builder: (context, snapshot) { - var speedSelected = snapshot.data; - return Wrap( - children: kSpeedToSelect - .map((e) => Padding( - padding: const EdgeInsets.only(right: 8.0), - child: FilterChip( - key: ValueKey(e.toString()), - label: Text('X ${e.toStringAsFixed(1)}'), - selectedColor: context.accentColor, - labelStyle: TextStyle( - color: snapshot.data!.contains(e) - ? Colors.white - : context.textColor), - elevation: 0, - showCheckmark: false, - selected: snapshot.data!.contains(e), - onSelected: (value) async { - if (!value) { - speedSelected!.remove(e); - } else { - speedSelected!.add(e); - } - await _saveSpeedList(speedSelected); - setState(() {}); - }, - ), - )) - .toList()); - }), + future: _getSpeedList(), + initialData: [], + builder: (context, snapshot) { + var speedSelected = snapshot.data; + return Wrap( + children: kSpeedToSelect + .map( + (e) => Padding( + padding: const EdgeInsets.only(right: 8.0), + child: FilterChip( + key: ValueKey(e.toString()), + label: Text('X ${e.toStringAsFixed(1)}'), + selectedColor: context.accentColor, + labelStyle: TextStyle( + color: snapshot.data!.contains(e) + ? Colors.white + : context.textColor), + elevation: 0, + showCheckmark: false, + selected: snapshot.data!.contains(e), + onSelected: (value) async { + if (!value) { + speedSelected!.remove(e); + } else { + speedSelected!.add(e); + } + await _saveSpeedList(speedSelected); + setState(() {}); + }, + ), + ), + ) + .toList(), + ); + }, + ), ], ), ); diff --git a/lib/type/search_api/search_top_podcast.g.dart b/lib/type/search_api/search_top_podcast.g.dart index 121343b..333790e 100644 --- a/lib/type/search_api/search_top_podcast.g.dart +++ b/lib/type/search_api/search_top_podcast.g.dart @@ -9,7 +9,7 @@ part of 'search_top_podcast.dart'; SearchTopPodcast _$SearchTopPodcastFromJson(Map json) { return SearchTopPodcast( podcasts: - (json['podcasts'] as List?)?.map(_ConvertT().fromJson)?.toList(), + (json['podcasts'] as List?)?.map(_ConvertT().fromJson).toList(), id: json['id'] as int?, total: json['total'] as int?, hasNext: json['has_next'] as bool?, @@ -20,7 +20,7 @@ SearchTopPodcast _$SearchTopPodcastFromJson(Map json) { Map _$SearchTopPodcastToJson( SearchTopPodcast instance) => { - 'podcasts': instance.podcasts?.map(_ConvertT().toJson)?.toList(), + 'podcasts': instance.podcasts?.map(_ConvertT().toJson).toList(), 'id': instance.id, 'page': instance.page, 'total': instance.total, diff --git a/lib/type/search_api/searchepisodes.g.dart b/lib/type/search_api/searchepisodes.g.dart index f6b2255..6ab1790 100644 --- a/lib/type/search_api/searchepisodes.g.dart +++ b/lib/type/search_api/searchepisodes.g.dart @@ -9,14 +9,14 @@ part of 'searchepisodes.dart'; SearchEpisodes _$SearchEpisodesFromJson(Map json) { return SearchEpisodes( episodes: - (json['episodes'] as List?)?.map(_ConvertE().fromJson)?.toList(), + (json['episodes'] as List?)?.map(_ConvertE().fromJson).toList(), nextEpisodeDate: json['next_episode_pub_date'] as int?, ); } Map _$SearchEpisodesToJson(SearchEpisodes instance) => { - 'episodes': instance.episodes?.map(_ConvertE().toJson)?.toList(), + 'episodes': instance.episodes?.map(_ConvertE().toJson).toList(), 'next_episode_pub_date': instance.nextEpisodeDate, }; diff --git a/lib/type/search_api/searchpodcast.g.dart b/lib/type/search_api/searchpodcast.g.dart index acd8ba4..b82eb45 100644 --- a/lib/type/search_api/searchpodcast.g.dart +++ b/lib/type/search_api/searchpodcast.g.dart @@ -8,7 +8,7 @@ part of 'searchpodcast.dart'; SearchPodcast

_$SearchPodcastFromJson

(Map json) { return SearchPodcast

( - results: (json['results'] as List?)?.map(_ConvertP

().fromJson)?.toList(), + results: (json['results'] as List?)?.map(_ConvertP

().fromJson).toList(), nextOffset: json['next_offset'] as int?, total: json['total'] as int?, count: json['count'] as int?, @@ -17,7 +17,7 @@ SearchPodcast

_$SearchPodcastFromJson

(Map json) { Map _$SearchPodcastToJson

(SearchPodcast

instance) => { - 'results': instance.results?.map(_ConvertP

().toJson)?.toList(), + 'results': instance.results?.map(_ConvertP

().toJson).toList(), 'next_offset': instance.nextOffset, 'total': instance.total, 'count': instance.count,