From 39a753711646cb15208025f079698058f9ec37ba Mon Sep 17 00:00:00 2001 From: PartyDonut Date: Sun, 5 Jan 2025 13:53:59 +0100 Subject: [PATCH] chore: Fix dart deprecation messages --- lib/main.dart | 3 +- lib/models/error_log_model.dart | 2 +- lib/models/item_editing_model.dart | 8 ++--- lib/models/items/media_streams_model.dart | 2 +- lib/models/playback/playback_model.dart | 2 +- .../settings/subtitle_settings_model.dart | 18 +++++------ .../items/book_details_provider.dart | 4 +-- .../items/episode_details_provider.dart | 2 +- .../items/series_details_provider.dart | 3 +- lib/providers/library_search_provider.dart | 20 ++++++------ .../book_viewer_settings_provider.dart | 9 +++--- .../settings/subtitle_settings_provider.dart | 2 +- .../video_player_settings_provider.dart | 6 ++-- .../sync/background_download_provider.dart | 3 +- lib/providers/sync_provider.dart | 4 +-- lib/providers/user_provider.dart | 3 +- lib/routes/nested_details_screen.dart | 2 +- .../book_viewer/book_viewer_controls.dart | 16 +++++----- lib/screens/crash_screen/crash_screen.dart | 4 +-- lib/screens/dashboard/dashboard_screen.dart | 3 +- .../details_screens/book_detail_screen.dart | 2 +- .../components/label_title_item.dart | 3 +- lib/screens/details_screens/empty_item.dart | 2 +- .../details_screens/person_detail_screen.dart | 19 +++++++----- lib/screens/home_screen.dart | 3 +- .../library_search/library_search_screen.dart | 2 +- .../widgets/library_saved_filters.dart | 6 +++- lib/screens/login/login_edit_user.dart | 1 + .../photo_viewer/photo_viewer_controls.dart | 17 +++++----- .../photo_viewer/photo_viewer_screen.dart | 4 +-- .../photo_viewer/simple_video_player.dart | 3 +- lib/screens/settings/settings_list_tile.dart | 2 +- lib/screens/settings/settings_screen.dart | 3 +- lib/screens/shared/default_alert_dialog.dart | 2 ++ lib/screens/shared/default_title_bar.dart | 19 ++++++------ lib/screens/shared/detail_scaffold.dart | 12 +++---- lib/screens/shared/file_picker.dart | 2 +- lib/screens/shared/flat_button.dart | 2 +- lib/screens/shared/input_fields.dart | 2 +- lib/screens/shared/media/carousel_banner.dart | 4 +-- lib/screens/shared/media/chapter_row.dart | 2 +- .../shared/media/components/chip_button.dart | 2 +- .../shared/media/components/media_header.dart | 2 +- .../media/components/media_play_button.dart | 1 + .../shared/media/components/poster_image.dart | 8 ++--- lib/screens/shared/media/episode_posters.dart | 4 +-- .../shared/media/expanding_overview.dart | 9 +++--- lib/screens/shared/media/media_banner.dart | 7 +++-- .../shared/media/poster_list_item.dart | 2 +- lib/screens/shared/media/season_row.dart | 4 +-- lib/screens/shared/outlined_text_field.dart | 12 +++---- lib/screens/syncing/sync_item_details.dart | 3 +- lib/screens/syncing/sync_list_item.dart | 2 +- lib/screens/syncing/sync_widgets.dart | 5 +-- .../syncing/widgets/sync_status_overlay.dart | 4 +-- .../components/video_player_next_wrapper.dart | 4 +-- .../video_player_options_sheet.dart | 4 +-- .../video_player_seek_indicator.dart | 2 +- .../components/video_progress_bar.dart | 9 +++--- .../components/video_subtitle_controls.dart | 12 +++---- .../video_player/video_player_controls.dart | 17 +++++----- lib/theme.dart | 2 +- lib/util/absorb_events.dart | 2 +- lib/util/color_extensions.dart | 31 +++++++++++++++++++ lib/util/debug_banner.dart | 2 +- lib/util/fab_extended_anim.dart | 1 + lib/util/humanize_duration.dart | 6 ++-- lib/util/keyed_list_view.dart | 8 +++-- lib/util/mouse_parking.dart | 2 +- lib/util/string_extensions.dart | 4 +-- .../components/fladder_app_bar.dart | 2 +- .../components/floating_player_bar.dart | 4 +-- .../components/navigation_button.dart | 13 ++++++-- lib/widgets/pop_up/delete_file.dart | 7 +++-- lib/widgets/shared/animated_icon.dart | 2 +- lib/widgets/shared/elevated_icon.dart | 8 ++--- lib/widgets/shared/fladder_carousel.dart | 6 ++-- lib/widgets/shared/fladder_scrollbar.dart | 2 +- lib/widgets/shared/item_actions.dart | 1 + lib/widgets/shared/modal_side_sheet.dart | 2 +- .../shared/selectable_icon_button.dart | 7 +++-- 81 files changed, 258 insertions(+), 195 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 66e46f4..57e6d57 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:collection/collection.dart'; import 'package:dynamic_color/dynamic_color.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -276,7 +275,7 @@ class _MainState extends ConsumerState
with WindowListener, WidgetsBinding dragDevices: { ...scrollBehaviour.dragDevices, mouseDrag ? PointerDeviceKind.mouse : null, - }.whereNotNull().toSet(), + }.nonNulls.toSet(), ), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, diff --git a/lib/models/error_log_model.dart b/lib/models/error_log_model.dart index 7c334e0..de2272c 100644 --- a/lib/models/error_log_model.dart +++ b/lib/models/error_log_model.dart @@ -62,7 +62,7 @@ class ErrorLogModel { "\n", "\n", stackTrace, - ].whereNotNull().join(); + ].nonNulls.join(); String get clipBoard => [_label, content].toString(); diff --git a/lib/models/item_editing_model.dart b/lib/models/item_editing_model.dart index 2c65493..fbbb280 100644 --- a/lib/models/item_editing_model.dart +++ b/lib/models/item_editing_model.dart @@ -1,14 +1,14 @@ import 'dart:typed_data'; -import 'package:collection/collection.dart'; -import 'package:fladder/models/items/series_model.dart'; import 'package:flutter/widgets.dart'; + import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:fladder/jellyfin/jellyfin_open_api.enums.swagger.dart'; import 'package:fladder/jellyfin/jellyfin_open_api.swagger.dart' as jelly; import 'package:fladder/models/item_base_model.dart'; import 'package:fladder/models/items/item_shared_models.dart'; +import 'package:fladder/models/items/series_model.dart'; import 'package:fladder/providers/image_provider.dart'; class EditItemsProvider { @@ -118,7 +118,7 @@ class ItemEditingModel { "OfficialRating": { for (String element in (editorInfo?.parentalRatingOptions?.map((e) => e.name).toSet() ?..add(json?["OfficialRating"] as String?)) - ?.whereNotNull() + ?.nonNulls .toList() ?? []) element: (editedJson?["OfficialRating"] as String?) == element @@ -126,7 +126,7 @@ class ItemEditingModel { "CustomRating": { for (String element in (editorInfo?.parentalRatingOptions?.map((e) => e.name).toSet() ?..add(json?["CustomRating"] as String?)) - ?.whereNotNull() + ?.nonNulls .toList() ?? []) element: (editedJson?["CustomRating"] as String?) == element diff --git a/lib/models/items/media_streams_model.dart b/lib/models/items/media_streams_model.dart index 28e2281..d677d3f 100644 --- a/lib/models/items/media_streams_model.dart +++ b/lib/models/items/media_streams_model.dart @@ -243,7 +243,7 @@ class AudioStreamModel extends StreamModel { } String get title => - [name, language, codec, channelLayout].whereNotNull().where((element) => element.isNotEmpty).join(' - '); + [name, language, codec, channelLayout].nonNulls.where((element) => element.isNotEmpty).join(' - '); AudioStreamModel.no({ super.name = 'Off', diff --git a/lib/models/playback/playback_model.dart b/lib/models/playback/playback_model.dart index 6a38a49..16cbdb1 100644 --- a/lib/models/playback/playback_model.dart +++ b/lib/models/playback/playback_model.dart @@ -132,7 +132,7 @@ class PlaybackModelHelper { trickPlay: syncedItem.trickPlayModel, mediaSegments: syncedItem.mediaSegments, media: Media(url: syncedItem.videoFile.path), - queue: itemQueue.whereNotNull().toList(), + queue: itemQueue.nonNulls.toList(), syncedQueue: children, mediaStreams: item.streamModel ?? syncedItemModel.streamModel, ); diff --git a/lib/models/settings/subtitle_settings_model.dart b/lib/models/settings/subtitle_settings_model.dart index 7ef4db6..e186ba1 100644 --- a/lib/models/settings/subtitle_settings_model.dart +++ b/lib/models/settings/subtitle_settings_model.dart @@ -1,4 +1,3 @@ -// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; import 'dart:math' as math; @@ -9,6 +8,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:fladder/providers/settings/subtitle_settings_provider.dart'; import 'package:fladder/providers/settings/video_player_settings_provider.dart'; +import 'package:fladder/util/color_extensions.dart'; class SubtitleSettingsModel { final double fontSize; @@ -58,11 +58,11 @@ class SubtitleSettingsModel { ? [ Shadow( blurRadius: 16, - color: Colors.black.withOpacity(shadow), + color: Colors.black.withValues(alpha: shadow), ), Shadow( blurRadius: 8, - color: Colors.black.withOpacity(shadow), + color: Colors.black.withValues(alpha: shadow), ), ] : null, @@ -92,10 +92,10 @@ class SubtitleSettingsModel { 'fontSize': fontSize, 'fontWeight': fontWeight.value, 'verticalOffset': verticalOffset, - 'color': color.value, - 'outlineColor': outlineColor.value, + 'color': color.toMap, + 'outlineColor': outlineColor.toMap, 'outlineSize': outlineSize, - 'backGroundColor': backGroundColor.value, + 'backGroundColor': backGroundColor.toMap, 'shadow': shadow, }; } @@ -109,10 +109,10 @@ class SubtitleSettingsModel { fontSize: map['fontSize'] as double?, fontWeight: FontWeight.values.firstWhereOrNull((element) => element.index == map['fontWeight'] as int?), verticalOffset: map['verticalOffset'] as double?, - color: map['color'] != null ? Color(map['color'] as int) : null, - outlineColor: map['outlineColor'] != null ? Color(map['outlineColor'] as int) : null, + color: colorFromJson(map['color']), + outlineColor: colorFromJson(map['outlineColor']), outlineSize: map['outlineSize'] as double?, - backGroundColor: map['backGroundColor'] != null ? Color(map['backGroundColor'] as int) : null, + backGroundColor: colorFromJson(map['backGroundColor']), shadow: map['shadow'] as double?, ); } diff --git a/lib/providers/items/book_details_provider.dart b/lib/providers/items/book_details_provider.dart index 05d5094..4109879 100644 --- a/lib/providers/items/book_details_provider.dart +++ b/lib/providers/items/book_details_provider.dart @@ -26,7 +26,7 @@ class BookProviderModel { ImagesData? get cover => parentModel?.getPosters ?? book?.getPosters; List get allBooks { - if (chapters.isEmpty) return [book].whereNotNull().toList(); + if (chapters.isEmpty) return [book].nonNulls.toList(); return chapters; } @@ -141,7 +141,7 @@ class BookDetailsProviderNotifier extends StateNotifier { state = state.copyWith( parentModel: !parentIsView ? () => parentResponse.bodyOrThrow : null, - chapters: (siblingsResponse?.body?.items ?? [openedBook]).whereType().whereNotNull().toList(), + chapters: (siblingsResponse?.body?.items ?? [openedBook]).whereType().nonNulls.toList(), ); return response; diff --git a/lib/providers/items/episode_details_provider.dart b/lib/providers/items/episode_details_provider.dart index 5c4b6da..6b84223 100644 --- a/lib/providers/items/episode_details_provider.dart +++ b/lib/providers/items/episode_details_provider.dart @@ -80,7 +80,7 @@ class EpisodeDetailsProvider extends StateNotifier { .map( (e) => e.createItemModel(ref), ) - .whereNotNull() + .nonNulls .whereType() .toList(); state = state.copyWith( diff --git a/lib/providers/items/series_details_provider.dart b/lib/providers/items/series_details_provider.dart index f39e25f..3bec5cb 100644 --- a/lib/providers/items/series_details_provider.dart +++ b/lib/providers/items/series_details_provider.dart @@ -1,5 +1,4 @@ import 'package:chopper/chopper.dart'; -import 'package:collection/collection.dart'; import 'package:fladder/models/item_base_model.dart'; import 'package:fladder/providers/service_provider.dart'; import 'package:fladder/providers/sync_provider.dart'; @@ -68,7 +67,7 @@ class SeriesDetailViewNotifier extends StateNotifier { .map( (e) => e.createItemModel(ref), ) - .whereNotNull() + .nonNulls .toList(); state = seriesModel.copyWith( availableEpisodes: allChildren.whereType().toList(), diff --git a/lib/providers/library_search_provider.dart b/lib/providers/library_search_provider.dart index ad23fdb..934c5e9 100644 --- a/lib/providers/library_search_provider.dart +++ b/lib/providers/library_search_provider.dart @@ -120,10 +120,10 @@ class LibrarySearchNotifier extends StateNotifier { newLastIndices[viewModel.id] = (lastIndices ?? 0) + libraryItems.items.length; } return libraryItems; - }).whereNotNull(), + }).nonNulls, ); - List newPosters = results.whereNotNull().expand((element) => element.items).toList(); + List newPosters = results.nonNulls.expand((element) => element.items).toList(); if (state.views.included.length > 1) { if (state.sortingOption == SortingOptions.random) { newPosters = newPosters.random(); @@ -220,7 +220,7 @@ class LibrarySearchNotifier extends StateNotifier { var tempState = state.copyWith(); final genres = mappedList .expand((element) => element?.genres ?? []) - .whereNotNull() + .nonNulls .sorted((a, b) => a.name!.toLowerCase().compareTo(b.name!.toLowerCase())); final tags = mappedList .expand((element) => element?.tags ?? []) @@ -437,7 +437,7 @@ class LibrarySearchNotifier extends StateNotifier { final response = await api.collectionsCollectionIdItemsDelete( collectionId: state.nestedCurrentItem?.id, ids: state.selectedPosters.map((e) => e.id).toList()); if (response.isSuccessful) { - removeFromPosters([state.nestedCurrentItem?.id].whereNotNull().toList()); + removeFromPosters([state.nestedCurrentItem?.id].nonNulls.toList()); } return response; } @@ -445,9 +445,9 @@ class LibrarySearchNotifier extends StateNotifier { Future removeSelectedFromPlaylist() async { final response = await api.playlistsPlaylistIdItemsDelete( playlistId: state.nestedCurrentItem?.id, - entryIds: state.selectedPosters.map((e) => e.playlistId).whereNotNull().toList()); + entryIds: state.selectedPosters.map((e) => e.playlistId).nonNulls.toList()); if (response.isSuccessful) { - removeFromPosters([state.nestedCurrentItem?.id].whereNotNull().toList()); + removeFromPosters([state.nestedCurrentItem?.id].nonNulls.toList()); } return response; } @@ -463,7 +463,7 @@ class LibrarySearchNotifier extends StateNotifier { Future removeFromPlaylist({required List items}) async { final response = await api.playlistsPlaylistIdItemsDelete( - playlistId: state.nestedCurrentItem?.id, entryIds: items.map((e) => e.playlistId).whereNotNull().toList()); + playlistId: state.nestedCurrentItem?.id, entryIds: items.map((e) => e.playlistId).nonNulls.toList()); if (response.isSuccessful) { removeFromPosters(items.map((e) => e.id).toList()); } @@ -489,7 +489,7 @@ class LibrarySearchNotifier extends StateNotifier { void updateUserDataMain(UserData? userData) { state = state.copyWith( - folderOverwrite: [state.folderOverwrite.lastOrNull?.copyWith(userData: userData)].whereNotNull().toList(), + folderOverwrite: [state.folderOverwrite.lastOrNull?.copyWith(userData: userData)].nonNulls.toList(), ); } @@ -529,10 +529,10 @@ class LibrarySearchNotifier extends StateNotifier { limit: limit, ); return libraryItems; - }).whereNotNull(), + }).nonNulls, ); - List newPosters = results.whereNotNull().expand((element) => element.items).toList(); + List newPosters = results.nonNulls.expand((element) => element.items).toList(); if (state.views.included.length > 1) { if (shuffle || state.sortingOption == SortingOptions.random) { newPosters = newPosters.random(); diff --git a/lib/providers/settings/book_viewer_settings_provider.dart b/lib/providers/settings/book_viewer_settings_provider.dart index a16bf56..c5eb4b3 100644 --- a/lib/providers/settings/book_viewer_settings_provider.dart +++ b/lib/providers/settings/book_viewer_settings_provider.dart @@ -1,7 +1,8 @@ import 'dart:convert'; -import 'package:collection/collection.dart'; import 'package:flutter/widgets.dart'; + +import 'package:collection/collection.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:screen_brightness/screen_brightness.dart'; @@ -124,15 +125,15 @@ class BookViewerSettingsNotifier extends StateNotifier screenBrightness: () => value, ); if (state.screenBrightness != null) { - ScreenBrightness().setScreenBrightness(state.screenBrightness!); + ScreenBrightness().setSystemScreenBrightness(state.screenBrightness!); } else { - ScreenBrightness().resetScreenBrightness(); + ScreenBrightness().resetApplicationScreenBrightness(); } } void setSavedBrightness() { if (state.screenBrightness != null) { - ScreenBrightness().setScreenBrightness(state.screenBrightness!); + ScreenBrightness().setSystemScreenBrightness(state.screenBrightness!); } } diff --git a/lib/providers/settings/subtitle_settings_provider.dart b/lib/providers/settings/subtitle_settings_provider.dart index b3271d0..98bf569 100644 --- a/lib/providers/settings/subtitle_settings_provider.dart +++ b/lib/providers/settings/subtitle_settings_provider.dart @@ -34,7 +34,7 @@ class SubtitleSettingsNotifier extends StateNotifier { void setFontWeight(FontWeight? value) => state = state.copyWith(fontWeight: value); SubtitleSettingsModel setBackGroundOpacity(double value) => - state = state.copyWith(backGroundColor: state.backGroundColor.withOpacity(value)); + state = state.copyWith(backGroundColor: state.backGroundColor.withValues(alpha: value)); SubtitleSettingsModel setShadowIntensity(double value) => state = state.copyWith(shadow: value); } diff --git a/lib/providers/settings/video_player_settings_provider.dart b/lib/providers/settings/video_player_settings_provider.dart index 0d7e7e5..eb691d3 100644 --- a/lib/providers/settings/video_player_settings_provider.dart +++ b/lib/providers/settings/video_player_settings_provider.dart @@ -33,15 +33,15 @@ class VideoPlayerSettingsProviderNotifier extends StateNotifier { return data.copyWith( primary: () => primary, logo: () => logo, - backDrop: () => backdrops.whereNotNull().toList(), + backDrop: () => backdrops.nonNulls.toList(), ); } @@ -381,7 +381,7 @@ class SyncNotifier extends StateNotifier { imageUrl: path.joinAll(["Chapters", fileName]), ); }).toList(); - return saveChapters.whereNotNull().toList(); + return saveChapters.nonNulls.toList(); } Future urlDataToFileData(ImageData? data, Directory directory, String fileName) async { diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 112e403..2735e37 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -1,5 +1,6 @@ import 'package:chopper/chopper.dart'; import 'package:collection/collection.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:fladder/jellyfin/enum_models.dart'; @@ -14,7 +15,7 @@ import 'package:fladder/providers/sync_provider.dart'; part 'user_provider.g.dart'; @riverpod -bool showSyncButtonProvider(ShowSyncButtonProviderRef ref) { +bool showSyncButtonProvider(Ref ref) { final userCanSync = ref.watch(userProvider.select((value) => value?.canDownload ?? false)); final hasSyncedItems = ref.watch(syncProvider.select((value) => value.items.isNotEmpty)); return userCanSync || hasSyncedItems; diff --git a/lib/routes/nested_details_screen.dart b/lib/routes/nested_details_screen.dart index e545855..d037e3d 100644 --- a/lib/routes/nested_details_screen.dart +++ b/lib/routes/nested_details_screen.dart @@ -69,7 +69,7 @@ class _DetailsScreenState extends ConsumerState { tag: widget.id, child: Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surface.withOpacity(1.0), + color: Theme.of(context).colorScheme.surface.withValues(alpha: 1.0), ), //Small offset to match detailscaffold child: Transform.translate( diff --git a/lib/screens/book_viewer/book_viewer_controls.dart b/lib/screens/book_viewer/book_viewer_controls.dart index dd1d121..f2a9ead 100644 --- a/lib/screens/book_viewer/book_viewer_controls.dart +++ b/lib/screens/book_viewer/book_viewer_controls.dart @@ -81,7 +81,7 @@ class _BookViewerControlsState extends ConsumerState { @override void dispose() { WakelockPlus.disable(); - ScreenBrightness().resetScreenBrightness(); + ScreenBrightness().resetApplicationScreenBrightness(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge, overlays: []); SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( statusBarColor: Colors.transparent, @@ -150,9 +150,9 @@ class _BookViewerControlsState extends ConsumerState { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - overlayColor.withOpacity(1), - overlayColor.withOpacity(0.65), - overlayColor.withOpacity(0), + overlayColor.withValues(alpha: 1), + overlayColor.withValues(alpha: 0.65), + overlayColor.withValues(alpha: 0), ], ), ), @@ -198,9 +198,9 @@ class _BookViewerControlsState extends ConsumerState { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - overlayColor.withOpacity(0), - overlayColor.withOpacity(0.65), - overlayColor.withOpacity(1), + overlayColor.withValues(alpha: 0), + overlayColor.withValues(alpha: 0.65), + overlayColor.withValues(alpha: 1), ], ), ), @@ -236,7 +236,7 @@ class _BookViewerControlsState extends ConsumerState { Flexible( child: Container( decoration: BoxDecoration( - color: Colors.black.withOpacity(0.7), + color: Colors.black.withValues(alpha: 0.7), borderRadius: BorderRadius.circular(60), ), child: Padding( diff --git a/lib/screens/crash_screen/crash_screen.dart b/lib/screens/crash_screen/crash_screen.dart index 88cfcfa..3ebfa1e 100644 --- a/lib/screens/crash_screen/crash_screen.dart +++ b/lib/screens/crash_screen/crash_screen.dart @@ -78,7 +78,7 @@ class CrashScreen extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Card( - color: e.color.withOpacity(0.1), + color: e.color.withValues(alpha: 0.1), margin: const EdgeInsets.symmetric(vertical: 12), child: Padding( padding: const EdgeInsets.all(8), @@ -90,7 +90,7 @@ class CrashScreen extends ConsumerWidget { children: [ Expanded( child: Card( - color: e.color.withOpacity(0.2), + color: e.color.withValues(alpha: 0.2), child: Padding( padding: const EdgeInsets.all(4.0), child: Text( diff --git a/lib/screens/dashboard/dashboard_screen.dart b/lib/screens/dashboard/dashboard_screen.dart index 927d66e..459b246 100644 --- a/lib/screens/dashboard/dashboard_screen.dart +++ b/lib/screens/dashboard/dashboard_screen.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:auto_route/auto_route.dart'; -import 'package:collection/collection.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:fladder/jellyfin/jellyfin_open_api.enums.swagger.dart'; @@ -179,7 +178,7 @@ class _DashboardScreenState extends ConsumerState { posters: view.recentlyAdded, ), )), - ].whereNotNull().toList().addInBetween(const SliverToBoxAdapter(child: SizedBox(height: 16))), + ].nonNulls.toList().addInBetween(const SliverToBoxAdapter(child: SizedBox(height: 16))), const DefautlSliverBottomPadding(), ], ), diff --git a/lib/screens/details_screens/book_detail_screen.dart b/lib/screens/details_screens/book_detail_screen.dart index 286229c..78fe3f6 100644 --- a/lib/screens/details_screens/book_detail_screen.dart +++ b/lib/screens/details_screens/book_detail_screen.dart @@ -56,7 +56,7 @@ class _BookDetailScreenState extends ConsumerState { } }, ), - backgroundColor: Theme.of(context).colorScheme.surface.withOpacity(0.8), + backgroundColor: Theme.of(context).colorScheme.surface.withValues(alpha: 0.8), onRefresh: () async => await ref.read(provider.notifier).fetchDetails(widget.item), backDrops: details.cover, content: (padding) => details.book != null diff --git a/lib/screens/details_screens/components/label_title_item.dart b/lib/screens/details_screens/components/label_title_item.dart index 69a7ebe..0c5f13e 100644 --- a/lib/screens/details_screens/components/label_title_item.dart +++ b/lib/screens/details_screens/components/label_title_item.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:collection/collection.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; class LabelTitleItem extends ConsumerWidget { @@ -32,7 +31,7 @@ class LabelTitleItem extends ConsumerWidget { label!, ) : content!, - ].whereNotNull().toList(), + ].nonNulls.toList(), ), ); } diff --git a/lib/screens/details_screens/empty_item.dart b/lib/screens/details_screens/empty_item.dart index 53339b8..795a198 100644 --- a/lib/screens/details_screens/empty_item.dart +++ b/lib/screens/details_screens/empty_item.dart @@ -50,7 +50,7 @@ class EmptyItem extends ConsumerWidget { shape: RoundedRectangleBorder( side: BorderSide( width: 1.0, - color: Colors.white.withOpacity(0.10), + color: Colors.white.withValues(alpha: 0.10), ), borderRadius: FladderTheme.defaultShape.borderRadius, ), diff --git a/lib/screens/details_screens/person_detail_screen.dart b/lib/screens/details_screens/person_detail_screen.dart index d37c6c7..9ca4433 100644 --- a/lib/screens/details_screens/person_detail_screen.dart +++ b/lib/screens/details_screens/person_detail_screen.dart @@ -1,4 +1,9 @@ +import 'package:flutter/material.dart'; + import 'package:collection/collection.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:intl/intl.dart'; + import 'package:fladder/models/items/item_shared_models.dart'; import 'package:fladder/providers/items/person_details_provider.dart'; import 'package:fladder/providers/user_provider.dart'; @@ -11,9 +16,6 @@ import 'package:fladder/util/list_extensions.dart'; import 'package:fladder/util/string_extensions.dart'; import 'package:fladder/util/widget_extensions.dart'; import 'package:fladder/widgets/shared/selectable_icon_button.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:intl/intl.dart'; class PersonDetailScreen extends ConsumerStatefulWidget { final Person person; @@ -37,6 +39,7 @@ class _PersonDetailScreenState extends ConsumerState { backDrops: [...?details?.movies, ...?details?.series].random().firstOrNull?.images, content: (padding) => Column( mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ SizedBox(height: MediaQuery.of(context).size.height / 6), Padding( @@ -89,10 +92,6 @@ class _PersonDetailScreenState extends ConsumerState { Text("Birthday: ${DateFormat.yMEd().format(details?.dateOfBirth ?? DateTime.now()).toString()}"), if (details?.age != null) Text("Age: ${details?.age}"), if (details?.birthPlace.isEmpty == false) Text("Born in ${details?.birthPlace.join(",")}"), - if (details?.overview.externalUrls?.isNotEmpty ?? false) - ExternalUrlsRow( - urls: details?.overview.externalUrls, - ).padding(padding), ], ), ], @@ -102,7 +101,11 @@ class _PersonDetailScreenState extends ConsumerState { if (details?.movies.isNotEmpty ?? false) PosterRow(contentPadding: padding, posters: details?.movies ?? [], label: "Movies"), if (details?.series.isNotEmpty ?? false) - PosterRow(contentPadding: padding, posters: details?.series ?? [], label: "Series") + PosterRow(contentPadding: padding, posters: details?.series ?? [], label: "Series"), + if (details?.overview.externalUrls?.isNotEmpty ?? false) + ExternalUrlsRow( + urls: details?.overview.externalUrls, + ).padding(padding), ], ), ); diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 8db6f38..45e82e6 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:auto_route/auto_route.dart'; -import 'package:collection/collection.dart'; import 'package:ficonsax/ficonsax.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -76,7 +75,7 @@ class HomeScreen extends ConsumerWidget { child: AutoRouter( builder: (context, child) { return NavigationScaffold( - destinations: destinations.whereNotNull().toList(), + destinations: destinations.nonNulls.toList(), currentRouteName: context.router.current.name, nestedChild: child, ); diff --git a/lib/screens/library_search/library_search_screen.dart b/lib/screens/library_search/library_search_screen.dart index 473ddc3..0c66d16 100644 --- a/lib/screens/library_search/library_search_screen.dart +++ b/lib/screens/library_search/library_search_screen.dart @@ -515,7 +515,7 @@ class _LibrarySearchScreenState extends ConsumerState { ), if (librarySearchResults.fetchingItems) ...[ Container( - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), ), Center( child: Container( diff --git a/lib/screens/library_search/widgets/library_saved_filters.dart b/lib/screens/library_search/widgets/library_saved_filters.dart index ad2db96..e19cb28 100644 --- a/lib/screens/library_search/widgets/library_saved_filters.dart +++ b/lib/screens/library_search/widgets/library_saved_filters.dart @@ -71,7 +71,9 @@ class LibrarySavedFiltersDialogue extends ConsumerWidget { tooltip: context.localized.defaultFilterForLibrary, style: ButtonStyle( backgroundColor: WidgetStatePropertyAll( - filter.isFavourite ? Colors.yellowAccent.shade700.withOpacity(0.5) : null, + filter.isFavourite + ? Colors.yellowAccent.shade700.withValues(alpha: 0.5) + : null, ), ), onPressed: () => @@ -107,6 +109,8 @@ class LibrarySavedFiltersDialogue extends ConsumerWidget { style: ButtonStyle( backgroundColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.errorContainer), + iconColor: + WidgetStatePropertyAll(Theme.of(context).colorScheme.onErrorContainer), foregroundColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.onErrorContainer), ), diff --git a/lib/screens/login/login_edit_user.dart b/lib/screens/login/login_edit_user.dart index c5ea1bb..ac96135 100644 --- a/lib/screens/login/login_edit_user.dart +++ b/lib/screens/login/login_edit_user.dart @@ -80,6 +80,7 @@ class LoginEditUser extends ConsumerWidget { child: ElevatedButton.icon( style: ElevatedButton.styleFrom( backgroundColor: Colors.red, + iconColor: Colors.white, foregroundColor: Colors.white, ), onPressed: () async { diff --git a/lib/screens/photo_viewer/photo_viewer_controls.dart b/lib/screens/photo_viewer/photo_viewer_controls.dart index 92b060e..5b3db22 100644 --- a/lib/screens/photo_viewer/photo_viewer_controls.dart +++ b/lib/screens/photo_viewer/photo_viewer_controls.dart @@ -136,10 +136,10 @@ class _PhotoViewerControllsState extends ConsumerState with @override Widget build(BuildContext context) { final gradient = [ - Colors.black.withOpacity(0.6), - Colors.black.withOpacity(0.3), - Colors.black.withOpacity(0.1), - Colors.black.withOpacity(0.0), + Colors.black.withValues(alpha: 0.6), + Colors.black.withValues(alpha: 0.3), + Colors.black.withValues(alpha: 0.1), + Colors.black.withValues(alpha: 0.0), ]; final padding = MediaQuery.of(context).padding; @@ -188,9 +188,12 @@ class _PhotoViewerControllsState extends ConsumerState with .textTheme .titleMedium ?.copyWith(fontWeight: FontWeight.bold, shadows: [ - BoxShadow(blurRadius: 1, spreadRadius: 1, color: Colors.black.withOpacity(0.7)), - BoxShadow(blurRadius: 4, spreadRadius: 4, color: Colors.black.withOpacity(0.4)), - BoxShadow(blurRadius: 20, spreadRadius: 6, color: Colors.black.withOpacity(0.2)), + BoxShadow( + blurRadius: 1, spreadRadius: 1, color: Colors.black.withValues(alpha: 0.7)), + BoxShadow( + blurRadius: 4, spreadRadius: 4, color: Colors.black.withValues(alpha: 0.4)), + BoxShadow( + blurRadius: 20, spreadRadius: 6, color: Colors.black.withValues(alpha: 0.2)), ]), ), ), diff --git a/lib/screens/photo_viewer/photo_viewer_screen.dart b/lib/screens/photo_viewer/photo_viewer_screen.dart index 3aa22f2..577bd63 100644 --- a/lib/screens/photo_viewer/photo_viewer_screen.dart +++ b/lib/screens/photo_viewer/photo_viewer_screen.dart @@ -384,8 +384,8 @@ class _PhotoViewerScreenState extends ConsumerState with Widg begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - Colors.black.withOpacity(0.5), - Colors.black.withOpacity(0), + Colors.black.withValues(alpha: 0.5), + Colors.black.withValues(alpha: 0), ], ), ), diff --git a/lib/screens/photo_viewer/simple_video_player.dart b/lib/screens/photo_viewer/simple_video_player.dart index 771745d..5e1edae 100644 --- a/lib/screens/photo_viewer/simple_video_player.dart +++ b/lib/screens/photo_viewer/simple_video_player.dart @@ -226,7 +226,8 @@ class _SimpleVideoPlayerState extends ConsumerState with Wind icon: Icon( player.lastState.playing ? IconsaxBold.pause_circle : IconsaxBold.play_circle, shadows: [ - BoxShadow(blurRadius: 16, spreadRadius: 2, color: Colors.black.withOpacity(0.15)) + BoxShadow( + blurRadius: 16, spreadRadius: 2, color: Colors.black.withValues(alpha: 0.15)) ], ), ) diff --git a/lib/screens/settings/settings_list_tile.dart b/lib/screens/settings/settings_list_tile.dart index 0490e3c..92f112c 100644 --- a/lib/screens/settings/settings_list_tile.dart +++ b/lib/screens/settings/settings_list_tile.dart @@ -47,7 +47,7 @@ class SettingsListTile extends StatelessWidget { child: AnimatedContainer( duration: const Duration(milliseconds: 125), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primaryContainer.withOpacity(selected ? 1 : 0), + color: Theme.of(context).colorScheme.primaryContainer.withValues(alpha: selected ? 1 : 0), borderRadius: BorderRadius.circular(selected ? 5 : 20), ), child: Padding( diff --git a/lib/screens/settings/settings_screen.dart b/lib/screens/settings/settings_screen.dart index 0a6b52a..55fbce6 100644 --- a/lib/screens/settings/settings_screen.dart +++ b/lib/screens/settings/settings_screen.dart @@ -95,7 +95,7 @@ class _SettingsScreenState extends ConsumerState { padding: const EdgeInsets.all(16.0), child: IconButton.filledTonal( style: IconButton.styleFrom( - backgroundColor: Theme.of(context).colorScheme.surface.withOpacity(0.8), + backgroundColor: Theme.of(context).colorScheme.surface.withValues(alpha: 0.8), ), onPressed: () => context.router.popBack(), icon: Padding( @@ -188,6 +188,7 @@ class _SettingsScreenState extends ConsumerState { ), ElevatedButton( style: ElevatedButton.styleFrom().copyWith( + iconColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.onErrorContainer), foregroundColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.onErrorContainer), backgroundColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.errorContainer), ), diff --git a/lib/screens/shared/default_alert_dialog.dart b/lib/screens/shared/default_alert_dialog.dart index 5228bb3..74e07cd 100644 --- a/lib/screens/shared/default_alert_dialog.dart +++ b/lib/screens/shared/default_alert_dialog.dart @@ -27,6 +27,7 @@ Future showDefaultAlertDialog( style: ElevatedButton.styleFrom( backgroundColor: Theme.of(context).colorScheme.errorContainer, foregroundColor: Theme.of(context).colorScheme.onErrorContainer, + iconColor: Theme.of(context).colorScheme.onErrorContainer, ), onPressed: () => accept.call(context), child: Text(acceptTitle ?? "Accept"), @@ -61,6 +62,7 @@ Future showDefaultActionDialog( style: ElevatedButton.styleFrom( backgroundColor: Theme.of(context).colorScheme.primaryContainer, foregroundColor: Theme.of(context).colorScheme.onPrimaryContainer, + iconColor: Theme.of(context).colorScheme.onPrimaryContainer, ), onPressed: () => accept.call(context), child: Text(acceptTitle ?? "Accept"), diff --git a/lib/screens/shared/default_title_bar.dart b/lib/screens/shared/default_title_bar.dart index 620daa4..73fa6af 100644 --- a/lib/screens/shared/default_title_bar.dart +++ b/lib/screens/shared/default_title_bar.dart @@ -33,12 +33,13 @@ class _DefaultTitleBarState extends ConsumerState with WindowLi final brightness = widget.brightness ?? Theme.of(context).brightness; final shadows = brightness == Brightness.dark ? [ - BoxShadow(blurRadius: 1, spreadRadius: 1, color: Theme.of(context).colorScheme.surface.withOpacity(1)), - BoxShadow(blurRadius: 8, spreadRadius: 2, color: Colors.black.withOpacity(0.2)), - BoxShadow(blurRadius: 3, spreadRadius: 2, color: Colors.black.withOpacity(0.3)), + BoxShadow( + blurRadius: 1, spreadRadius: 1, color: Theme.of(context).colorScheme.surface.withValues(alpha: 1)), + BoxShadow(blurRadius: 8, spreadRadius: 2, color: Colors.black.withValues(alpha: 0.2)), + BoxShadow(blurRadius: 3, spreadRadius: 2, color: Colors.black.withValues(alpha: 0.3)), ] : []; - final iconColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.65); + final iconColor = Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.65); return SizedBox( height: widget.height, child: switch (AdaptiveLayout.of(context).platform) { @@ -47,7 +48,7 @@ class _DefaultTitleBarState extends ConsumerState with WindowLi children: [ Expanded( child: Container( - color: Colors.black.withOpacity(0), + color: Colors.black.withValues(alpha: 0), child: DragToMoveArea( child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -77,8 +78,8 @@ class _DefaultTitleBarState extends ConsumerState with WindowLi return IconButton( style: IconButton.styleFrom( hoverColor: brightness == Brightness.light - ? Colors.black.withOpacity(0.1) - : Colors.white.withOpacity(0.2), + ? Colors.black.withValues(alpha: 0.1) + : Colors.white.withValues(alpha: 0.2), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2))), onPressed: () async { if (isMinimized) { @@ -110,8 +111,8 @@ class _DefaultTitleBarState extends ConsumerState with WindowLi return IconButton( style: IconButton.styleFrom( hoverColor: brightness == Brightness.light - ? Colors.black.withOpacity(0.1) - : Colors.white.withOpacity(0.2), + ? Colors.black.withValues(alpha: 0.1) + : Colors.white.withValues(alpha: 0.2), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)), ), onPressed: () async { diff --git a/lib/screens/shared/detail_scaffold.dart b/lib/screens/shared/detail_scaffold.dart index fed3e1b..59f99c7 100644 --- a/lib/screens/shared/detail_scaffold.dart +++ b/lib/screens/shared/detail_scaffold.dart @@ -62,7 +62,7 @@ class _DetailScaffoldState extends ConsumerState { @override Widget build(BuildContext context) { final padding = EdgeInsets.symmetric(horizontal: MediaQuery.sizeOf(context).width / 25); - final backGroundColor = Theme.of(context).colorScheme.surface.withOpacity(0.8); + final backGroundColor = Theme.of(context).colorScheme.surface.withValues(alpha: 0.8); final playerState = ref.watch(mediaPlaybackProvider.select((value) => value.state)); final minHeight = 450.0.clamp(0, MediaQuery.sizeOf(context).height).toDouble(); final maxHeight = MediaQuery.sizeOf(context).height - 10; @@ -114,7 +114,7 @@ class _DetailScaffoldState extends ConsumerState { Colors.white, Colors.white, Colors.white, - Colors.white.withOpacity(0), + Colors.white.withValues(alpha: 0), ], ).createShader(bounds), child: ConstrainedBox( @@ -145,10 +145,10 @@ class _DetailScaffoldState extends ConsumerState { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - Theme.of(context).colorScheme.surface.withOpacity(0), - Theme.of(context).colorScheme.surface.withOpacity(0.10), - Theme.of(context).colorScheme.surface.withOpacity(0.35), - Theme.of(context).colorScheme.surface.withOpacity(0.85), + Theme.of(context).colorScheme.surface.withValues(alpha: 0), + Theme.of(context).colorScheme.surface.withValues(alpha: 0.10), + Theme.of(context).colorScheme.surface.withValues(alpha: 0.35), + Theme.of(context).colorScheme.surface.withValues(alpha: 0.85), Theme.of(context).colorScheme.surface, ], ), diff --git a/lib/screens/shared/file_picker.dart b/lib/screens/shared/file_picker.dart index c9d5622..659313e 100644 --- a/lib/screens/shared/file_picker.dart +++ b/lib/screens/shared/file_picker.dart @@ -59,7 +59,7 @@ class _FilePickerBarState extends ConsumerState { @override Widget build(BuildContext context) { final offColor = Theme.of(context).colorScheme.secondaryContainer; - final onColor = Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.7); + final onColor = Theme.of(context).colorScheme.secondaryContainer.withValues(alpha: 0.7); final contentColor = Theme.of(context).colorScheme.onSecondaryContainer; return DropTarget( enable: !inputField, diff --git a/lib/screens/shared/flat_button.dart b/lib/screens/shared/flat_button.dart index 633271f..c943d79 100644 --- a/lib/screens/shared/flat_button.dart +++ b/lib/screens/shared/flat_button.dart @@ -47,7 +47,7 @@ class FlatButton extends ConsumerWidget { onDoubleTap: onDoubleTap, onSecondaryTapDown: onSecondaryTapDown, borderRadius: borderRadiusGeometry ?? BorderRadius.circular(10), - splashColor: splashColor ?? Theme.of(context).colorScheme.primary.withOpacity(0.5), + splashColor: splashColor ?? Theme.of(context).colorScheme.primary.withValues(alpha: 0.5), hoverColor: showFeedback ? null : Colors.transparent, splashFactory: InkSparkle.splashFactory, ), diff --git a/lib/screens/shared/input_fields.dart b/lib/screens/shared/input_fields.dart index 30f9a39..315491e 100644 --- a/lib/screens/shared/input_fields.dart +++ b/lib/screens/shared/input_fields.dart @@ -20,7 +20,7 @@ class IntInputField extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return Card( - color: Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.25), + color: Theme.of(context).colorScheme.secondaryContainer.withValues(alpha: 0.25), elevation: 0, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 6), diff --git a/lib/screens/shared/media/carousel_banner.dart b/lib/screens/shared/media/carousel_banner.dart index d448c8b..7bcd8cc 100644 --- a/lib/screens/shared/media/carousel_banner.dart +++ b/lib/screens/shared/media/carousel_banner.dart @@ -69,7 +69,7 @@ class _CarouselBannerState extends ConsumerState { begin: Alignment.bottomLeft, end: Alignment.topCenter, colors: [ - ThemesData.of(context).dark.colorScheme.primaryContainer.withOpacity(0.85), + ThemesData.of(context).dark.colorScheme.primaryContainer.withValues(alpha: 0.85), Colors.transparent, ], ), @@ -144,7 +144,7 @@ class _CarouselBannerState extends ConsumerState { child: Container( decoration: BoxDecoration( border: Border.all( - color: Colors.white.withOpacity(0.1), + color: Colors.white.withValues(alpha: 0.1), width: 1.0, ), borderRadius: border), diff --git a/lib/screens/shared/media/chapter_row.dart b/lib/screens/shared/media/chapter_row.dart index 1e306da..83d0e48 100644 --- a/lib/screens/shared/media/chapter_row.dart +++ b/lib/screens/shared/media/chapter_row.dart @@ -52,7 +52,7 @@ class ChapterRow extends ConsumerWidget { child: Card( elevation: 0, shadowColor: Colors.transparent, - color: Theme.of(context).cardColor.withOpacity(0.4), + color: Theme.of(context).cardColor.withValues(alpha: 0.4), child: Padding( padding: const EdgeInsets.all(5), child: Text( diff --git a/lib/screens/shared/media/components/chip_button.dart b/lib/screens/shared/media/components/chip_button.dart index 13b5355..f515631 100644 --- a/lib/screens/shared/media/components/chip_button.dart +++ b/lib/screens/shared/media/components/chip_button.dart @@ -12,7 +12,7 @@ class ChipButton extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return Card( - color: Theme.of(context).colorScheme.onSurface.withOpacity(0.15), + color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.15), shadowColor: Colors.transparent, child: FlatButton( onTap: onPressed, diff --git a/lib/screens/shared/media/components/media_header.dart b/lib/screens/shared/media/components/media_header.dart index 48829e5..4562fbe 100644 --- a/lib/screens/shared/media/components/media_header.dart +++ b/lib/screens/shared/media/components/media_header.dart @@ -35,7 +35,7 @@ class MediaHeader extends ConsumerWidget { child: Material( elevation: 30, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(150)), - shadowColor: Colors.black.withOpacity(0.3), + shadowColor: Colors.black.withValues(alpha: 0.3), color: Colors.transparent, child: ConstrainedBox( constraints: BoxConstraints( diff --git a/lib/screens/shared/media/components/media_play_button.dart b/lib/screens/shared/media/components/media_play_button.dart index edba27a..78a45ec 100644 --- a/lib/screens/shared/media/components/media_play_button.dart +++ b/lib/screens/shared/media/components/media_play_button.dart @@ -67,6 +67,7 @@ class MediaPlayButton extends ConsumerWidget { ButtonStyle( backgroundColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.primary), foregroundColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.onPrimary), + iconColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.onPrimary), ), Theme.of(context).colorScheme.onPrimary, ), diff --git a/lib/screens/shared/media/components/poster_image.dart b/lib/screens/shared/media/components/poster_image.dart index 00ccefc..9cf1f22 100644 --- a/lib/screens/shared/media/components/poster_image.dart +++ b/lib/screens/shared/media/components/poster_image.dart @@ -99,7 +99,7 @@ class _PosterImageState extends ConsumerState { shape: RoundedRectangleBorder( side: BorderSide( width: 1.0, - color: Colors.white.withOpacity(0.10), + color: Colors.white.withValues(alpha: 0.10), ), borderRadius: FladderTheme.defaultShape.borderRadius, ), @@ -133,7 +133,7 @@ class _PosterImageState extends ConsumerState { if (widget.selected == true) Container( decoration: BoxDecoration( - color: Colors.black.withOpacity(0.15), + color: Colors.black.withValues(alpha: 0.15), border: Border.all(width: 3, color: Theme.of(context).colorScheme.primary), borderRadius: FladderTheme.defaultShape.borderRadius, ), @@ -191,7 +191,7 @@ class _PosterImageState extends ConsumerState { shadowColor: Colors.transparent, child: LinearProgressIndicator( minHeight: 7.5, - backgroundColor: Theme.of(context).colorScheme.onPrimary.withOpacity(0.5), + backgroundColor: Theme.of(context).colorScheme.onPrimary.withValues(alpha: 0.5), value: poster.userData.progress / 100, borderRadius: BorderRadius.circular(2), ), @@ -213,7 +213,7 @@ class _PosterImageState extends ConsumerState { //Hover color overlay Container( decoration: BoxDecoration( - color: Colors.black.withOpacity(0.55), + color: Colors.black.withValues(alpha: 0.55), border: Border.all(width: 3, color: Theme.of(context).colorScheme.primary), borderRadius: FladderTheme.defaultShape.borderRadius, )), diff --git a/lib/screens/shared/media/episode_posters.dart b/lib/screens/shared/media/episode_posters.dart index 24d1ee3..7e60d29 100644 --- a/lib/screens/shared/media/episode_posters.dart +++ b/lib/screens/shared/media/episode_posters.dart @@ -231,7 +231,7 @@ class EpisodePoster extends ConsumerWidget { alignment: Alignment.bottomCenter, child: LinearProgressIndicator( minHeight: 6, - backgroundColor: Colors.black.withOpacity(0.75), + backgroundColor: Colors.black.withValues(alpha: 0.75), value: episode.userData.progress / 100, ), ), @@ -260,7 +260,7 @@ class EpisodePoster extends ConsumerWidget { Icons.more_vert, color: Colors.white, shadows: [ - Shadow(color: Colors.black.withOpacity(0.45), blurRadius: 8.0), + Shadow(color: Colors.black.withValues(alpha: 0.45), blurRadius: 8.0), const Shadow(color: Colors.black, blurRadius: 16.0), const Shadow(color: Colors.black, blurRadius: 32.0), const Shadow(color: Colors.black, blurRadius: 64.0), diff --git a/lib/screens/shared/media/expanding_overview.dart b/lib/screens/shared/media/expanding_overview.dart index 1567e02..28b6503 100644 --- a/lib/screens/shared/media/expanding_overview.dart +++ b/lib/screens/shared/media/expanding_overview.dart @@ -44,11 +44,12 @@ class _ExpandingOverviewState extends ConsumerState { stops: const [0, 1], colors: [ color, - color.withOpacity(!canExpand - ? 1 - : expanded + color.withValues( + alpha: !canExpand ? 1 - : 0), + : expanded + ? 1 + : 0), ], ).createShader(bounds), child: HtmlWidget( diff --git a/lib/screens/shared/media/media_banner.dart b/lib/screens/shared/media/media_banner.dart index 9e9c897..d8e4ca7 100644 --- a/lib/screens/shared/media/media_banner.dart +++ b/lib/screens/shared/media/media_banner.dart @@ -141,12 +141,13 @@ class _MediaBannerState extends ConsumerState { foregroundDecoration: BoxDecoration( borderRadius: BorderRadius.circular(14), border: Border.all( - color: Colors.white.withOpacity(0.10), strokeAlign: BorderSide.strokeAlignInside), + color: Colors.white.withValues(alpha: 0.10), + strokeAlign: BorderSide.strokeAlignInside), gradient: LinearGradient( begin: Alignment.bottomLeft, end: Alignment.topCenter, colors: [ - overlayColor.withOpacity(0.85), + overlayColor.withValues(alpha: 0.85), Colors.transparent, ], ), @@ -238,7 +239,7 @@ class _MediaBannerState extends ConsumerState { maxLines: 2, style: Theme.of(context).textTheme.titleMedium?.copyWith( shadows: shadows, - color: Colors.white.withOpacity(0.75), + color: Colors.white.withValues(alpha: 0.75), ), ), ), diff --git a/lib/screens/shared/media/poster_list_item.dart b/lib/screens/shared/media/poster_list_item.dart index df4bdad..1305700 100644 --- a/lib/screens/shared/media/poster_list_item.dart +++ b/lib/screens/shared/media/poster_list_item.dart @@ -61,7 +61,7 @@ class PosterListItem extends ConsumerWidget { height: 75 * ref.read(clientSettingsProvider.select((value) => value.posterSize)), child: Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary.withOpacity(selected == true ? 0.25 : 0), + color: Theme.of(context).colorScheme.primary.withValues(alpha: selected == true ? 0.25 : 0), borderRadius: BorderRadius.circular(6), ), child: FlatButton( diff --git a/lib/screens/shared/media/season_row.dart b/lib/screens/shared/media/season_row.dart index 0d51cd5..6e344c2 100644 --- a/lib/screens/shared/media/season_row.dart +++ b/lib/screens/shared/media/season_row.dart @@ -60,7 +60,7 @@ class SeasonPoster extends ConsumerWidget { padding: const EdgeInsets.all(4), child: Container( child: Card( - color: Theme.of(context).colorScheme.surface.withOpacity(0.65), + color: Theme.of(context).colorScheme.surface.withValues(alpha: 0.65), child: Padding( padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12), child: Text( @@ -159,7 +159,7 @@ class SeasonPoster extends ConsumerWidget { Icons.more_vert, color: Colors.white, shadows: [ - Shadow(color: Colors.black.withOpacity(0.45), blurRadius: 8.0), + Shadow(color: Colors.black.withValues(alpha: 0.45), blurRadius: 8.0), const Shadow(color: Colors.black, blurRadius: 16.0), const Shadow(color: Colors.black, blurRadius: 32.0), const Shadow(color: Colors.black, blurRadius: 64.0), diff --git a/lib/screens/shared/outlined_text_field.dart b/lib/screens/shared/outlined_text_field.dart index 10a4e34..cf6c96f 100644 --- a/lib/screens/shared/outlined_text_field.dart +++ b/lib/screens/shared/outlined_text_field.dart @@ -63,7 +63,7 @@ class _OutlinedTextFieldState extends ConsumerState { Color getColor() { if (widget.errorText != null) return Theme.of(context).colorScheme.errorContainer; - return Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.25); + return Theme.of(context).colorScheme.secondaryContainer.withValues(alpha: 0.25); } @override @@ -112,31 +112,31 @@ class _OutlinedTextFieldState extends ConsumerState { decoration: InputDecoration( border: OutlineInputBorder( borderSide: BorderSide( - color: Theme.of(context).colorScheme.primary.withOpacity(0), + color: Theme.of(context).colorScheme.primary.withValues(alpha: 0), width: widget.borderWidth, ), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: Theme.of(context).colorScheme.primary.withOpacity(0), + color: Theme.of(context).colorScheme.primary.withValues(alpha: 0), width: widget.borderWidth, ), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: Theme.of(context).colorScheme.primary.withOpacity(0), + color: Theme.of(context).colorScheme.primary.withValues(alpha: 0), width: widget.borderWidth, ), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: Theme.of(context).colorScheme.primary.withOpacity(0), + color: Theme.of(context).colorScheme.primary.withValues(alpha: 0), width: widget.borderWidth, ), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: Theme.of(context).colorScheme.primary.withOpacity(0), + color: Theme.of(context).colorScheme.primary.withValues(alpha: 0), width: widget.borderWidth, ), ), diff --git a/lib/screens/syncing/sync_item_details.dart b/lib/screens/syncing/sync_item_details.dart index d7df958..5f1c0a2 100644 --- a/lib/screens/syncing/sync_item_details.dart +++ b/lib/screens/syncing/sync_item_details.dart @@ -153,7 +153,7 @@ class _SyncItemDetailsState extends ConsumerState { CircularProgressIndicator( value: combinedStream.progress, strokeWidth: 8, - backgroundColor: Theme.of(context).colorScheme.surface.withOpacity(0.5), + backgroundColor: Theme.of(context).colorScheme.surface.withValues(alpha: 0.5), strokeCap: StrokeCap.round, color: combinedStream.status.color(context), ), @@ -212,6 +212,7 @@ class _SyncItemDetailsState extends ConsumerState { style: ElevatedButton.styleFrom( backgroundColor: Theme.of(context).colorScheme.errorContainer, foregroundColor: Theme.of(context).colorScheme.onErrorContainer, + iconColor: Theme.of(context).colorScheme.onErrorContainer, ), onPressed: () { showDefaultAlertDialog( diff --git a/lib/screens/syncing/sync_list_item.dart b/lib/screens/syncing/sync_list_item.dart index 1784706..ac5f3a8 100644 --- a/lib/screens/syncing/sync_list_item.dart +++ b/lib/screens/syncing/sync_list_item.dart @@ -35,7 +35,7 @@ class SyncListItemState extends ConsumerState { syncedItem: syncedItem, child: Card( elevation: 1, - color: Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.2), + color: Theme.of(context).colorScheme.secondaryContainer.withValues(alpha: 0.2), shadowColor: Colors.transparent, child: Dismissible( background: Container( diff --git a/lib/screens/syncing/sync_widgets.dart b/lib/screens/syncing/sync_widgets.dart index 2a461fb..4fbfd51 100644 --- a/lib/screens/syncing/sync_widgets.dart +++ b/lib/screens/syncing/sync_widgets.dart @@ -24,7 +24,7 @@ class SyncLabel extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { return Container( decoration: BoxDecoration( - color: status.color.withOpacity(0.15), + color: status.color.withValues(alpha: 0.15), borderRadius: BorderRadius.circular(10), ), child: Padding( @@ -109,7 +109,8 @@ class SyncSubtitle extends ConsumerWidget { final children = syncItem.nestedChildren(ref); final syncStatus = ref.watch(syncStatusesProvider(syncItem)).value ?? SyncStatus.partially; return Container( - decoration: BoxDecoration(color: syncStatus.color.withOpacity(0.15), borderRadius: BorderRadius.circular(10)), + decoration: + BoxDecoration(color: syncStatus.color.withValues(alpha: 0.15), borderRadius: BorderRadius.circular(10)), child: Material( color: const Color.fromARGB(0, 208, 130, 130), textStyle: diff --git a/lib/screens/syncing/widgets/sync_status_overlay.dart b/lib/screens/syncing/widgets/sync_status_overlay.dart index 04d80cf..c1884fd 100644 --- a/lib/screens/syncing/widgets/sync_status_overlay.dart +++ b/lib/screens/syncing/widgets/sync_status_overlay.dart @@ -22,7 +22,7 @@ class SyncStatusOverlay extends ConsumerWidget { child: Card( elevation: 0, semanticContainer: false, - color: Colors.black.withOpacity(0.6), + color: Colors.black.withValues(alpha: 0.6), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, @@ -44,7 +44,7 @@ class SyncStatusOverlay extends ConsumerWidget { child: Card( elevation: 0, semanticContainer: false, - color: Colors.black.withOpacity(0.6), + color: Colors.black.withValues(alpha: 0.6), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/screens/video_player/components/video_player_next_wrapper.dart b/lib/screens/video_player/components/video_player_next_wrapper.dart index 3928f0a..e8068a3 100644 --- a/lib/screens/video_player/components/video_player_next_wrapper.dart +++ b/lib/screens/video_player/components/video_player_next_wrapper.dart @@ -130,7 +130,7 @@ class _VideoPlayerNextWrapperState extends ConsumerState Future clearOverlaySettings() async { if (AdaptiveLayout.of(context).inputDevice != InputDevice.pointer) { - ScreenBrightness().resetScreenBrightness(); + ScreenBrightness().resetApplicationScreenBrightness(); } else { closeFullScreen(); } @@ -161,7 +161,7 @@ class _VideoPlayerNextWrapperState extends ConsumerState child: Stack( children: [ Container( - color: Theme.of(context).colorScheme.surfaceContainerLowest.withOpacity(0.2), + color: Theme.of(context).colorScheme.surfaceContainerLowest.withValues(alpha: 0.2), ), if (nextUp != null) AnimatedAlign( diff --git a/lib/screens/video_player/components/video_player_options_sheet.dart b/lib/screens/video_player/components/video_player_options_sheet.dart index 273890e..ab89962 100644 --- a/lib/screens/video_player/components/video_player_options_sheet.dart +++ b/lib/screens/video_player/components/video_player_options_sheet.dart @@ -393,7 +393,7 @@ Future showSubSelection(BuildContext context) { final selected = playbackModel.mediaStreams?.defaultSubStreamIndex == subModel.index; return ListTile( title: Text(subModel.label(context)), - tileColor: selected ? Theme.of(context).colorScheme.primary.withOpacity(0.3) : null, + tileColor: selected ? Theme.of(context).colorScheme.primary.withValues(alpha: 0.3) : null, subtitle: subModel.language.isNotEmpty ? Opacity(opacity: 0.6, child: Text(subModel.language.capitalize())) : null, @@ -434,7 +434,7 @@ Future showAudioSelection(BuildContext context) { final selected = playbackModel.mediaStreams?.defaultAudioStreamIndex == audioStream.index; return ListTile( title: Text(audioStream.label(context)), - tileColor: selected ? Theme.of(context).colorScheme.primary.withOpacity(0.3) : null, + tileColor: selected ? Theme.of(context).colorScheme.primary.withValues(alpha: 0.3) : null, subtitle: audioStream.language.isNotEmpty ? Opacity(opacity: 0.6, child: Text(audioStream.language.capitalize())) : null, diff --git a/lib/screens/video_player/components/video_player_seek_indicator.dart b/lib/screens/video_player/components/video_player_seek_indicator.dart index 365cbf9..82babbc 100644 --- a/lib/screens/video_player/components/video_player_seek_indicator.dart +++ b/lib/screens/video_player/components/video_player_seek_indicator.dart @@ -84,7 +84,7 @@ class _VideoPlayerSeekIndicatorState extends ConsumerState { .clamp(1, constraints.maxWidth), height: sliderHeight, child: GappedContainerShape( - activeColor: Theme.of(context).colorScheme.primary.withOpacity(0.5), - inActiveColor: Theme.of(context).colorScheme.primary.withOpacity(0.5), + activeColor: Theme.of(context).colorScheme.primary.withValues(alpha: 0.5), + inActiveColor: Theme.of(context).colorScheme.primary.withValues(alpha: 0.5), thumbPosition: bufferFraction, ), ), @@ -196,7 +195,7 @@ class _ChapterProgressSliderState extends ConsumerState { shape: BoxShape.circle, color: activePosition ? Theme.of(context).colorScheme.onPrimary - : Theme.of(context).colorScheme.onSurface.withOpacity(0.5), + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.5), ), height: constraints.maxHeight, width: sliderHeight - (activePosition ? 2 : 4), @@ -204,7 +203,7 @@ class _ChapterProgressSliderState extends ConsumerState { ), ); }, - ).whereNotNull(), + ).nonNulls, }, ], ), diff --git a/lib/screens/video_player/components/video_subtitle_controls.dart b/lib/screens/video_player/components/video_subtitle_controls.dart index a9c1837..c881cf4 100644 --- a/lib/screens/video_player/components/video_subtitle_controls.dart +++ b/lib/screens/video_player/components/video_subtitle_controls.dart @@ -15,7 +15,7 @@ Future showSubtitleControls({ }) async { await showDialog( context: context, - barrierColor: Colors.black.withOpacity(0.1), + barrierColor: Colors.black.withValues(alpha: 0.1), builder: (context) => AlertDialog( backgroundColor: Colors.transparent, elevation: 0, @@ -60,7 +60,7 @@ class _VideoSubtitleControlsState extends ConsumerState { duration: const Duration(milliseconds: 250), decoration: BoxDecoration( borderRadius: BorderRadius.circular(16), - color: controlsHidden ? Theme.of(context).dialogBackgroundColor.withOpacity(0.75) : Colors.transparent, + color: controlsHidden ? Theme.of(context).dialogBackgroundColor.withValues(alpha: 0.75) : Colors.transparent, ), child: Padding( padding: const EdgeInsets.all(16), @@ -220,8 +220,8 @@ class _VideoSubtitleControlsState extends ConsumerState { const Icon(Icons.border_color_rounded), ...[Colors.white, Colors.yellow, Colors.black, Colors.grey, Colors.transparent].map( (e) => FlatButton( - onTap: () => - provider.setOutlineColor(e == Colors.transparent ? e : e.withOpacity(0.85)), + onTap: () => provider + .setOutlineColor(e == Colors.transparent ? e : e.withValues(alpha: 0.85)), borderRadiusGeometry: BorderRadius.circular(5), clipBehavior: Clip.antiAlias, child: Container( @@ -284,7 +284,7 @@ class _VideoSubtitleControlsState extends ConsumerState { divisions: 20, onChangeStart: (value) => setOpacity(const Key('backGroundOpacity')), onChangeEnd: (value) => setOpacity(null), - value: subSettings.backGroundColor.opacity.clamp(0, 1), + value: subSettings.backGroundColor.a.clamp(0, 1), onChanged: (value) => provider.setBackGroundOpacity(value), ), ), @@ -293,7 +293,7 @@ class _VideoSubtitleControlsState extends ConsumerState { minWidth: 35, ), child: Text( - subSettings.backGroundColor.opacity.toStringAsFixed(2), + subSettings.backGroundColor.a.toStringAsFixed(2), textAlign: TextAlign.center, ), ), diff --git a/lib/screens/video_player/video_player_controls.dart b/lib/screens/video_player/video_player_controls.dart index 1c45765..7a75714 100644 --- a/lib/screens/video_player/video_player_controls.dart +++ b/lib/screens/video_player/video_player_controls.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:async/async.dart'; -import 'package:collection/collection.dart'; import 'package:ficonsax/ficonsax.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:screen_brightness/screen_brightness.dart'; @@ -219,8 +218,8 @@ class _DesktopControlsState extends ConsumerState { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - Colors.black.withOpacity(0.8), - Colors.black.withOpacity(0), + Colors.black.withValues(alpha: 0.8), + Colors.black.withValues(alpha: 0), ], )), child: Padding( @@ -276,8 +275,8 @@ class _DesktopControlsState extends ConsumerState { begin: Alignment.bottomCenter, end: Alignment.topCenter, colors: [ - Colors.black.withOpacity(0.8), - Colors.black.withOpacity(0), + Colors.black.withValues(alpha: 0.8), + Colors.black.withValues(alpha: 0), ], )), child: Padding( @@ -425,7 +424,7 @@ class _DesktopControlsState extends ConsumerState { children: [ Expanded( child: Text( - details.whereNotNull().join(' - '), + details.nonNulls.join(' - '), style: Theme.of(context).textTheme.titleMedium?.copyWith( fontWeight: FontWeight.bold, shadows: [ @@ -506,7 +505,7 @@ class _DesktopControlsState extends ConsumerState { textAlign: TextAlign.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), - color: Theme.of(context).colorScheme.surface.withOpacity(0.95), + color: Theme.of(context).colorScheme.surface.withValues(alpha: 0.95), ), textStyle: Theme.of(context).textTheme.labelLarge, child: IconButton( @@ -533,7 +532,7 @@ class _DesktopControlsState extends ConsumerState { textAlign: TextAlign.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), - color: Theme.of(context).colorScheme.surface.withOpacity(0.95), + color: Theme.of(context).colorScheme.surface.withValues(alpha: 0.95), ), textStyle: Theme.of(context).textTheme.labelLarge, child: IconButton( @@ -625,7 +624,7 @@ class _DesktopControlsState extends ConsumerState { Future clearOverlaySettings() async { toggleOverlay(value: true); if (AdaptiveLayout.of(context).inputDevice != InputDevice.pointer) { - ScreenBrightness().resetScreenBrightness(); + ScreenBrightness().resetApplicationScreenBrightness(); } else { disableFullScreen(); } diff --git a/lib/theme.dart b/lib/theme.dart index 4391ecf..f9b521d 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -114,7 +114,7 @@ class FladderTheme { ), buttonTheme: ButtonThemeData(shape: defaultShape), chipTheme: ChipThemeData( - side: BorderSide(width: 1, color: scheme?.onSurface.withOpacity(0.05) ?? Colors.white), + side: BorderSide(width: 1, color: scheme?.onSurface.withValues(alpha: 0.05) ?? Colors.white), shape: defaultShape, ), popupMenuTheme: PopupMenuThemeData( diff --git a/lib/util/absorb_events.dart b/lib/util/absorb_events.dart index 399c6ac..f17e784 100644 --- a/lib/util/absorb_events.dart +++ b/lib/util/absorb_events.dart @@ -13,7 +13,7 @@ class AbsorbEvents extends ConsumerWidget { onDoubleTap: () {}, onTap: () {}, onLongPress: () {}, - child: Container(color: Colors.black.withOpacity(0), child: child), + child: Container(color: Colors.black.withValues(alpha: 0), child: child), ); } else { return child; diff --git a/lib/util/color_extensions.dart b/lib/util/color_extensions.dart index e934e31..813cef5 100644 --- a/lib/util/color_extensions.dart +++ b/lib/util/color_extensions.dart @@ -2,6 +2,37 @@ import 'package:flutter/material.dart'; import 'package:fladder/util/localization_helper.dart'; +Color? colorFromJson(dynamic color) { + if (color == null) return null; + + if (color is Map) { + return Color.from( + alpha: color['alpha'] ?? 1.0, + red: color['red'] ?? 1.0, + green: color['green'] ?? 1.0, + blue: color['blue'] ?? 1.0, + ); + } + + // Deprecated format (integer value) + if (color is int) { + return Color(color); + } + + return null; +} + +extension ColorExtensions on Color { + Map get toMap { + return { + 'alpha': a, + 'red': r, + 'green': g, + 'blue': b, + }; + } +} + extension DynamicSchemeVariantExtension on DynamicSchemeVariant { String label(BuildContext context) => switch (this) { DynamicSchemeVariant.tonalSpot => context.localized.schemeSettingsTonalSpot, diff --git a/lib/util/debug_banner.dart b/lib/util/debug_banner.dart index 3e4be50..7cfa111 100644 --- a/lib/util/debug_banner.dart +++ b/lib/util/debug_banner.dart @@ -29,7 +29,7 @@ class DebugBanner extends ConsumerWidget { padding: const EdgeInsets.all(4.0), child: Card( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)), - color: Colors.purpleAccent.withOpacity(0.8), + color: Colors.purpleAccent.withValues(alpha: 0.8), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2), child: Text( diff --git a/lib/util/fab_extended_anim.dart b/lib/util/fab_extended_anim.dart index 920a0f1..dc7e73f 100644 --- a/lib/util/fab_extended_anim.dart +++ b/lib/util/fab_extended_anim.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'package:flutter_riverpod/flutter_riverpod.dart'; class FloatingActionButtonAnimated extends ConsumerWidget { diff --git a/lib/util/humanize_duration.dart b/lib/util/humanize_duration.dart index 64cad1d..d19fad9 100644 --- a/lib/util/humanize_duration.dart +++ b/lib/util/humanize_duration.dart @@ -1,5 +1,3 @@ -import 'package:collection/collection.dart'; - extension DurationExtensions on Duration? { String? get humanize { if (this == null) return null; @@ -7,7 +5,7 @@ extension DurationExtensions on Duration? { final hours = duration.inHours != 0 ? '${duration.inHours.toString()}h' : null; final minutes = duration.inMinutes % 60 != 0 ? '${duration.inMinutes % 60}m'.padLeft(3, '0') : null; final seconds = duration.inSeconds % 60 != 0 ? '${duration.inSeconds % 60}s'.padLeft(3, '0') : null; - final result = [hours, minutes, seconds].whereNotNull().map((e) => e).join(' '); + final result = [hours, minutes, seconds].nonNulls.map((e) => e).join(' '); return result.isNotEmpty ? result : null; } @@ -18,7 +16,7 @@ extension DurationExtensions on Duration? { final minutes = (duration.inMinutes % 60).toString().padLeft(2, '0'); final seconds = (duration.inHours == 0 ? duration.inSeconds % 60 : null)?.toString().padLeft(2, '0'); - final result = [hours, minutes, seconds].whereNotNull().map((e) => e).join(':'); + final result = [hours, minutes, seconds].nonNulls.map((e) => e).join(':'); return result.isNotEmpty ? result : null; } diff --git a/lib/util/keyed_list_view.dart b/lib/util/keyed_list_view.dart index 3aacd22..bf38921 100644 --- a/lib/util/keyed_list_view.dart +++ b/lib/util/keyed_list_view.dart @@ -1,5 +1,6 @@ -import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; + +import 'package:collection/collection.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; @@ -69,9 +70,12 @@ class _KeyedListViewState extends ConsumerState { style: TextButton.styleFrom( padding: EdgeInsets.zero, textStyle: Theme.of(context).textTheme.titleSmall?.copyWith(fontWeight: FontWeight.bold), + iconColor: atPosition + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.35), foregroundColor: atPosition ? Theme.of(context).colorScheme.onSecondary - : Theme.of(context).colorScheme.onSurface.withOpacity(0.35), + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.35), ), onPressed: () { itemScrollController.scrollTo( diff --git a/lib/util/mouse_parking.dart b/lib/util/mouse_parking.dart index e6df68d..3dc010e 100644 --- a/lib/util/mouse_parking.dart +++ b/lib/util/mouse_parking.dart @@ -24,7 +24,7 @@ class _MouseParkingState extends ConsumerState { child: Container( decoration: BoxDecoration( borderRadius: const BorderRadius.only(topLeft: Radius.circular(20)), - color: parked ? Theme.of(context).colorScheme.primary.withOpacity(0.5) : Colors.black12, + color: parked ? Theme.of(context).colorScheme.primary.withValues(alpha: 0.5) : Colors.black12, ), child: const Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/util/string_extensions.dart b/lib/util/string_extensions.dart index 34cf204..d3b479f 100644 --- a/lib/util/string_extensions.dart +++ b/lib/util/string_extensions.dart @@ -1,5 +1,3 @@ -import 'package:collection/collection.dart'; - import 'package:fladder/models/items/item_shared_models.dart'; extension StringExtensions on String { @@ -64,6 +62,6 @@ extension GenreExtensions on List { extension StringListExtension on List { String get detailsTitle { - return whereNotNull().join(" ● "); + return nonNulls.join(" ● "); } } diff --git a/lib/widgets/navigation_scaffold/components/fladder_app_bar.dart b/lib/widgets/navigation_scaffold/components/fladder_app_bar.dart index 3f0c62a..563e21a 100644 --- a/lib/widgets/navigation_scaffold/components/fladder_app_bar.dart +++ b/lib/widgets/navigation_scaffold/components/fladder_app_bar.dart @@ -43,7 +43,7 @@ class FladderAppBar extends StatelessWidget implements PreferredSize { } else { return AppBar( toolbarHeight: 0, - backgroundColor: Theme.of(context).colorScheme.surface.withOpacity(0), + backgroundColor: Theme.of(context).colorScheme.surface.withValues(alpha: 0), scrolledUnderElevation: 0, elevation: 0, systemOverlayStyle: const SystemUiOverlayStyle(), diff --git a/lib/widgets/navigation_scaffold/components/floating_player_bar.dart b/lib/widgets/navigation_scaffold/components/floating_player_bar.dart index e01ce2f..8703cde 100644 --- a/lib/widgets/navigation_scaffold/components/floating_player_bar.dart +++ b/lib/widgets/navigation_scaffold/components/floating_player_bar.dart @@ -116,7 +116,7 @@ class _CurrentlyPlayingBarState extends ConsumerState { opacity: showExpandButton ? 1 : 0, duration: const Duration(milliseconds: 125), child: Container( - color: Colors.black.withOpacity(0.6), + color: Colors.black.withValues(alpha: 0.6), child: FlatButton( onTap: () async => openFullScreenPlayer(), child: const Icon(Icons.keyboard_arrow_up_rounded), @@ -191,7 +191,7 @@ class _CurrentlyPlayingBarState extends ConsumerState { ), LinearProgressIndicator( minHeight: 6, - backgroundColor: Colors.black.withOpacity(0.25), + backgroundColor: Colors.black.withValues(alpha: 0.25), color: Theme.of(context).colorScheme.primary, value: progress.clamp(0, 1), ), diff --git a/lib/widgets/navigation_scaffold/components/navigation_button.dart b/lib/widgets/navigation_scaffold/components/navigation_button.dart index 34c7b7a..ebb00af 100644 --- a/lib/widgets/navigation_scaffold/components/navigation_button.dart +++ b/lib/widgets/navigation_scaffold/components/navigation_button.dart @@ -1,7 +1,9 @@ -import 'package:fladder/util/widget_extensions.dart'; import 'package:flutter/material.dart'; + import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:fladder/util/widget_extensions.dart'; + class NavigationButton extends ConsumerStatefulWidget { final String? label; final Widget selectedIcon; @@ -58,10 +60,15 @@ class _NavigationButtonState extends ConsumerState { elevation: const WidgetStatePropertyAll(0), padding: const WidgetStatePropertyAll(EdgeInsets.zero), backgroundColor: const WidgetStatePropertyAll(Colors.transparent), + iconColor: WidgetStateProperty.resolveWith((states) { + return widget.selected + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.45); + }), foregroundColor: WidgetStateProperty.resolveWith((states) { return widget.selected ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.onSurface.withOpacity(0.45); + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.45); })), onPressed: widget.onPressed, child: AnimatedContainer( @@ -94,7 +101,7 @@ class _NavigationButtonState extends ConsumerState { width: widget.selected ? 14 : 0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), - color: Theme.of(context).colorScheme.primary.withOpacity(widget.selected ? 1 : 0), + color: Theme.of(context).colorScheme.primary.withValues(alpha: widget.selected ? 1 : 0), ), ), ], diff --git a/lib/widgets/pop_up/delete_file.dart b/lib/widgets/pop_up/delete_file.dart index ce6feaf..0a3ba48 100644 --- a/lib/widgets/pop_up/delete_file.dart +++ b/lib/widgets/pop_up/delete_file.dart @@ -1,10 +1,12 @@ +import 'package:flutter/material.dart'; + import 'package:chopper/chopper.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + import 'package:fladder/models/item_base_model.dart'; import 'package:fladder/providers/api_provider.dart'; import 'package:fladder/util/localization_helper.dart'; import 'package:fladder/widgets/shared/filled_button_await.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; Future?> showDeleteDialog(BuildContext context, ItemBaseModel item, WidgetRef ref) async { Response? response; @@ -23,6 +25,7 @@ Future?> showDeleteDialog(BuildContext context, ItemBaseModel style: FilledButton.styleFrom( backgroundColor: Theme.of(context).colorScheme.errorContainer, foregroundColor: Theme.of(context).colorScheme.onErrorContainer, + iconColor: Theme.of(context).colorScheme.onErrorContainer, ), onPressed: () async { response = await ref.read(jellyApiProvider).deleteItem(item.id); diff --git a/lib/widgets/shared/animated_icon.dart b/lib/widgets/shared/animated_icon.dart index b5275cc..c7e3386 100644 --- a/lib/widgets/shared/animated_icon.dart +++ b/lib/widgets/shared/animated_icon.dart @@ -72,7 +72,7 @@ class AnimatedVisibilityIconState extends State { child: AnimatedContainer( duration: const Duration(milliseconds: 300), decoration: BoxDecoration( - color: (_currentFilledState ? widget.filledColor : widget.outlinedColor)?.withOpacity(0.2), + color: (_currentFilledState ? widget.filledColor : widget.outlinedColor)?.withValues(alpha: 0.2), shape: BoxShape.circle, ), child: Padding( diff --git a/lib/widgets/shared/elevated_icon.dart b/lib/widgets/shared/elevated_icon.dart index 502090e..e5c0703 100644 --- a/lib/widgets/shared/elevated_icon.dart +++ b/lib/widgets/shared/elevated_icon.dart @@ -20,9 +20,9 @@ IconData getBackIcon(BuildContext context) { } final _shadows = [ - BoxShadow(blurRadius: 1, spreadRadius: 1, color: Colors.black.withOpacity(0.2)), - BoxShadow(blurRadius: 4, spreadRadius: 4, color: Colors.black.withOpacity(0.1)), - BoxShadow(blurRadius: 16, spreadRadius: 6, color: Colors.black.withOpacity(0.2)), + BoxShadow(blurRadius: 1, spreadRadius: 1, color: Colors.black.withValues(alpha: 0.2)), + BoxShadow(blurRadius: 4, spreadRadius: 4, color: Colors.black.withValues(alpha: 0.1)), + BoxShadow(blurRadius: 16, spreadRadius: 6, color: Colors.black.withValues(alpha: 0.2)), ]; class ElevatedIconButton extends ConsumerWidget { @@ -36,7 +36,7 @@ class ElevatedIconButton extends ConsumerWidget { return IconButton( onPressed: onPressed, style: IconButtonTheme.of(context).style?.copyWith( - backgroundColor: WidgetStatePropertyAll(color?.withOpacity(0.15)), + backgroundColor: WidgetStatePropertyAll(color?.withValues(alpha: 0.15)), ), color: color, icon: Icon( diff --git a/lib/widgets/shared/fladder_carousel.dart b/lib/widgets/shared/fladder_carousel.dart index f7408d1..f6671a4 100644 --- a/lib/widgets/shared/fladder_carousel.dart +++ b/lib/widgets/shared/fladder_carousel.dart @@ -295,13 +295,13 @@ class _CarouselViewState extends State { overlayColor: widget.overlayColor ?? WidgetStateProperty.resolveWith((Set states) { if (states.contains(WidgetState.pressed)) { - return theme.colorScheme.onSurface.withOpacity(0.1); + return theme.colorScheme.onSurface.withValues(alpha: 0.1); } if (states.contains(WidgetState.hovered)) { - return theme.colorScheme.onSurface.withOpacity(0.08); + return theme.colorScheme.onSurface.withValues(alpha: 0.08); } if (states.contains(WidgetState.focused)) { - return theme.colorScheme.onSurface.withOpacity(0.1); + return theme.colorScheme.onSurface.withValues(alpha: 0.1); } return null; }), diff --git a/lib/widgets/shared/fladder_scrollbar.dart b/lib/widgets/shared/fladder_scrollbar.dart index bfe8e39..c95d87b 100644 --- a/lib/widgets/shared/fladder_scrollbar.dart +++ b/lib/widgets/shared/fladder_scrollbar.dart @@ -28,7 +28,7 @@ class FladderScrollbar extends ConsumerWidget { borderRadius: BorderRadius.circular(5), color: info.isDragging ? Theme.of(context).colorScheme.secondary - : Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.75), + : Theme.of(context).colorScheme.secondaryContainer.withValues(alpha: 0.75), ), duration: const Duration(milliseconds: 250), ); diff --git a/lib/widgets/shared/item_actions.dart b/lib/widgets/shared/item_actions.dart index 4df9f4c..274cc37 100644 --- a/lib/widgets/shared/item_actions.dart +++ b/lib/widgets/shared/item_actions.dart @@ -95,6 +95,7 @@ class ItemActionButton extends ItemAction { minimumSize: const WidgetStatePropertyAll(Size(50, 50)), elevation: const WidgetStatePropertyAll(0), foregroundColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.onSurface), + iconColor: WidgetStatePropertyAll(Theme.of(context).colorScheme.onSurface), ), onPressed: () { if (shouldPop) { diff --git a/lib/widgets/shared/modal_side_sheet.dart b/lib/widgets/shared/modal_side_sheet.dart index e51eb1f..360a8a0 100644 --- a/lib/widgets/shared/modal_side_sheet.dart +++ b/lib/widgets/shared/modal_side_sheet.dart @@ -16,7 +16,7 @@ Future showModalSideSheet( context: context, transitionDuration: transitionDuration ?? const Duration(milliseconds: 200), barrierDismissible: barrierDismissible, - barrierColor: Theme.of(context).colorScheme.scrim.withOpacity(0.3), + barrierColor: Theme.of(context).colorScheme.scrim.withValues(alpha: 0.3), barrierLabel: 'Material 3 side sheet', useRootNavigator: false, transitionBuilder: (context, animation, secondaryAnimation, child) { diff --git a/lib/widgets/shared/selectable_icon_button.dart b/lib/widgets/shared/selectable_icon_button.dart index 63036a3..277e9d1 100644 --- a/lib/widgets/shared/selectable_icon_button.dart +++ b/lib/widgets/shared/selectable_icon_button.dart @@ -1,10 +1,12 @@ import 'dart:async'; import 'dart:developer'; +import 'package:flutter/material.dart'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; + import 'package:fladder/screens/shared/animated_fade_size.dart'; import 'package:fladder/util/refresh_state.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; class SelectableIconButton extends ConsumerStatefulWidget { final FutureOr Function() onPressed; @@ -36,6 +38,7 @@ class _SelectableIconButtonState extends ConsumerState { child: ElevatedButton( style: ButtonStyle( backgroundColor: widget.selected ? WidgetStatePropertyAll(Theme.of(context).colorScheme.primary) : null, + iconColor: widget.selected ? WidgetStatePropertyAll(Theme.of(context).colorScheme.onPrimary) : null, foregroundColor: widget.selected ? WidgetStatePropertyAll(Theme.of(context).colorScheme.onPrimary) : null, padding: const WidgetStatePropertyAll(EdgeInsets.zero), ),