From 7afbdfaa846636cdf04fb29c3112466df58a1e6f Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Tue, 15 Aug 2023 23:59:29 +0200 Subject: [PATCH] pattern switches --- lib/model/filters/mime.dart | 14 +- lib/model/filters/missing.dart | 17 +- lib/model/filters/placeholder.dart | 17 +- lib/model/filters/type.dart | 26 +- lib/ref/bursts.dart | 26 +- lib/view/src/actions/chip.dart | 33 +-- lib/view/src/actions/chip_set.dart | 131 +++------ lib/view/src/actions/entry.dart | 275 +++++++----------- lib/view/src/actions/entry_set.dart | 186 +++++------- lib/view/src/actions/map.dart | 27 +- lib/view/src/actions/map_cluster.dart | 21 +- lib/view/src/actions/share.dart | 21 +- lib/view/src/actions/slideshow.dart | 27 +- lib/view/src/editor/enums.dart | 54 ++-- lib/view/src/metadata/date_edit_action.dart | 23 +- lib/view/src/metadata/date_field_source.dart | 19 +- lib/view/src/metadata/length_unit.dart | 11 +- .../src/metadata/location_edit_action.dart | 17 +- lib/view/src/metadata/metadata_type.dart | 34 +-- lib/view/src/source/album.dart | 25 +- lib/view/src/source/state.dart | 19 +- lib/view/src/source/vault.dart | 17 +- .../common/behaviour/pop/tv_navigation.dart | 24 +- .../edit_description_dialog.dart | 11 +- .../dialogs/pick_dialogs/album_pick_page.dart | 19 +- lib/widgets/filter_grids/common/enums.dart | 72 ++--- lib/widgets/settings/app_export/items.dart | 27 +- .../settings/video/subtitle_theme.dart | 17 +- untranslated.json | 74 +---- 29 files changed, 458 insertions(+), 826 deletions(-) diff --git a/lib/model/filters/mime.dart b/lib/model/filters/mime.dart index 1cdc1f052..341780c53 100644 --- a/lib/model/filters/mime.dart +++ b/lib/model/filters/mime.dart @@ -68,14 +68,12 @@ class MimeFilter extends CollectionFilter { @override String getLabel(BuildContext context) { - switch (mime) { - case MimeTypes.anyImage: - return context.l10n.filterMimeImageLabel; - case MimeTypes.anyVideo: - return context.l10n.filterMimeVideoLabel; - default: - return _label; - } + final l10n = context.l10n; + return switch (mime) { + MimeTypes.anyImage => l10n.filterMimeImageLabel, + MimeTypes.anyVideo => l10n.filterMimeVideoLabel, + _ => _label, + }; } @override diff --git a/lib/model/filters/missing.dart b/lib/model/filters/missing.dart index 9128d1eb1..9d83f82c3 100644 --- a/lib/model/filters/missing.dart +++ b/lib/model/filters/missing.dart @@ -60,16 +60,13 @@ class MissingFilter extends CollectionFilter { @override String getLabel(BuildContext context) { - switch (metadataType) { - case _date: - return context.l10n.filterNoDateLabel; - case _fineAddress: - return context.l10n.filterNoAddressLabel; - case _title: - return context.l10n.filterNoTitleLabel; - default: - return metadataType; - } + final l10n = context.l10n; + return switch (metadataType) { + _date => l10n.filterNoDateLabel, + _fineAddress => l10n.filterNoAddressLabel, + _title => l10n.filterNoTitleLabel, + _ => metadataType, + }; } @override diff --git a/lib/model/filters/placeholder.dart b/lib/model/filters/placeholder.dart index bbeab3bed..ea8fdb093 100644 --- a/lib/model/filters/placeholder.dart +++ b/lib/model/filters/placeholder.dart @@ -86,16 +86,13 @@ class PlaceholderFilter extends CollectionFilter { @override String getLabel(BuildContext context) { - switch (placeholder) { - case _country: - return context.l10n.tagPlaceholderCountry; - case _state: - return context.l10n.tagPlaceholderState; - case _place: - return context.l10n.tagPlaceholderPlace; - default: - return placeholder; - } + final l10n = context.l10n; + return switch (placeholder) { + _country => l10n.tagPlaceholderCountry, + _state => l10n.tagPlaceholderState, + _place => l10n.tagPlaceholderPlace, + _ => placeholder, + }; } @override diff --git a/lib/model/filters/type.dart b/lib/model/filters/type.dart index b94dcb6ac..a095887dc 100644 --- a/lib/model/filters/type.dart +++ b/lib/model/filters/type.dart @@ -80,22 +80,16 @@ class TypeFilter extends CollectionFilter { @override String getLabel(BuildContext context) { - switch (itemType) { - case _animated: - return context.l10n.filterTypeAnimatedLabel; - case _motionPhoto: - return context.l10n.filterTypeMotionPhotoLabel; - case _panorama: - return context.l10n.filterTypePanoramaLabel; - case _raw: - return context.l10n.filterTypeRawLabel; - case _sphericalVideo: - return context.l10n.filterTypeSphericalVideoLabel; - case _geotiff: - return context.l10n.filterTypeGeotiffLabel; - default: - return itemType; - } + final l10n = context.l10n; + return switch (itemType) { + _animated => l10n.filterTypeAnimatedLabel, + _motionPhoto => l10n.filterTypeMotionPhotoLabel, + _panorama => l10n.filterTypePanoramaLabel, + _raw => l10n.filterTypeRawLabel, + _sphericalVideo => l10n.filterTypeSphericalVideoLabel, + _geotiff => l10n.filterTypeGeotiffLabel, + _ => itemType, + }; } @override diff --git a/lib/ref/bursts.dart b/lib/ref/bursts.dart index 51b587664..65e590a19 100644 --- a/lib/ref/bursts.dart +++ b/lib/ref/bursts.dart @@ -10,25 +10,19 @@ class BurstPatterns { ]; static String getName(String pattern) { - switch (pattern) { - case samsung: - return 'Samsung'; - case sony: - return 'Sony'; - default: - return pattern; - } + return switch (pattern) { + samsung => 'Samsung', + sony => 'Sony', + _ => pattern, + }; } static String getExample(String pattern) { - switch (pattern) { - case samsung: - return '20151021_072800_007'; - case sony: - return 'DSC_0007_BURST20151021072800123'; - default: - return '?'; - } + return switch (pattern) { + samsung => '20151021_072800_007', + sony => 'DSC_0007_BURST20151021072800123', + _ => '?', + }; } static const byManufacturer = { diff --git a/lib/view/src/actions/chip.dart b/lib/view/src/actions/chip.dart index 0dc57af26..6c6dcc6cc 100644 --- a/lib/view/src/actions/chip.dart +++ b/lib/view/src/actions/chip.dart @@ -5,27 +5,22 @@ import 'package:flutter/widgets.dart'; extension ExtraChipActionView on ChipAction { String getText(BuildContext context) { - switch (this) { - case ChipAction.goToAlbumPage: - return context.l10n.chipActionGoToAlbumPage; - case ChipAction.goToCountryPage: - return context.l10n.chipActionGoToCountryPage; - case ChipAction.goToPlacePage: - return context.l10n.chipActionGoToPlacePage; - case ChipAction.goToTagPage: - return context.l10n.chipActionGoToTagPage; - case ChipAction.ratingOrGreater: - case ChipAction.ratingOrLower: + final l10n = context.l10n; + return switch (this) { + ChipAction.goToAlbumPage => l10n.chipActionGoToAlbumPage, + ChipAction.goToCountryPage => l10n.chipActionGoToCountryPage, + ChipAction.goToPlacePage => l10n.chipActionGoToPlacePage, + ChipAction.goToTagPage => l10n.chipActionGoToTagPage, + ChipAction.ratingOrGreater || + ChipAction.ratingOrLower => // different data depending on state - return toString(); - case ChipAction.reverse: + toString(), + ChipAction.reverse => // different data depending on state - return context.l10n.chipActionFilterOut; - case ChipAction.hide: - return context.l10n.chipActionHide; - case ChipAction.lockVault: - return context.l10n.chipActionLock; - } + l10n.chipActionFilterOut, + ChipAction.hide => l10n.chipActionHide, + ChipAction.lockVault => l10n.chipActionLock, + }; } Widget getIcon() => Icon(_getIconData()); diff --git a/lib/view/src/actions/chip_set.dart b/lib/view/src/actions/chip_set.dart index f178505ab..596c45e26 100644 --- a/lib/view/src/actions/chip_set.dart +++ b/lib/view/src/actions/chip_set.dart @@ -5,106 +5,69 @@ import 'package:flutter/material.dart'; extension ExtraChipSetActionView on ChipSetAction { String getText(BuildContext context) { - switch (this) { + final l10n = context.l10n; + return switch (this) { // general - case ChipSetAction.configureView: - return context.l10n.menuActionConfigureView; - case ChipSetAction.select: - return context.l10n.menuActionSelect; - case ChipSetAction.selectAll: - return context.l10n.menuActionSelectAll; - case ChipSetAction.selectNone: - return context.l10n.menuActionSelectNone; + ChipSetAction.configureView => l10n.menuActionConfigureView, + ChipSetAction.select => l10n.menuActionSelect, + ChipSetAction.selectAll => l10n.menuActionSelectAll, + ChipSetAction.selectNone => l10n.menuActionSelectNone, // browsing - case ChipSetAction.search: - return MaterialLocalizations.of(context).searchFieldLabel; - case ChipSetAction.toggleTitleSearch: + ChipSetAction.search => MaterialLocalizations.of(context).searchFieldLabel, + ChipSetAction.toggleTitleSearch => // different data depending on toggle state - return context.l10n.collectionActionShowTitleSearch; - case ChipSetAction.createAlbum: - return context.l10n.chipActionCreateAlbum; - case ChipSetAction.createVault: - return context.l10n.chipActionCreateVault; + l10n.collectionActionShowTitleSearch, + ChipSetAction.createAlbum => l10n.chipActionCreateAlbum, + ChipSetAction.createVault => l10n.chipActionCreateVault, // browsing or selecting - case ChipSetAction.map: - return context.l10n.menuActionMap; - case ChipSetAction.slideshow: - return context.l10n.menuActionSlideshow; - case ChipSetAction.stats: - return context.l10n.menuActionStats; + ChipSetAction.map => l10n.menuActionMap, + ChipSetAction.slideshow => l10n.menuActionSlideshow, + ChipSetAction.stats => l10n.menuActionStats, // selecting (single/multiple filters) - case ChipSetAction.delete: - return context.l10n.chipActionDelete; - case ChipSetAction.hide: - return context.l10n.chipActionHide; - case ChipSetAction.pin: - return context.l10n.chipActionPin; - case ChipSetAction.unpin: - return context.l10n.chipActionUnpin; - case ChipSetAction.lockVault: - return context.l10n.chipActionLock; - case ChipSetAction.showCountryStates: - return context.l10n.chipActionShowCountryStates; + ChipSetAction.delete => l10n.chipActionDelete, + ChipSetAction.hide => l10n.chipActionHide, + ChipSetAction.pin => l10n.chipActionPin, + ChipSetAction.unpin => l10n.chipActionUnpin, + ChipSetAction.lockVault => l10n.chipActionLock, + ChipSetAction.showCountryStates => l10n.chipActionShowCountryStates, // selecting (single filter) - case ChipSetAction.rename: - return context.l10n.chipActionRename; - case ChipSetAction.setCover: - return context.l10n.chipActionSetCover; - case ChipSetAction.configureVault: - return context.l10n.chipActionConfigureVault; - } + ChipSetAction.rename => l10n.chipActionRename, + ChipSetAction.setCover => l10n.chipActionSetCover, + ChipSetAction.configureVault => l10n.chipActionConfigureVault, + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { + return switch (this) { // general - case ChipSetAction.configureView: - return AIcons.view; - case ChipSetAction.select: - return AIcons.select; - case ChipSetAction.selectAll: - return AIcons.selected; - case ChipSetAction.selectNone: - return AIcons.unselected; + ChipSetAction.configureView => AIcons.view, + ChipSetAction.select => AIcons.select, + ChipSetAction.selectAll => AIcons.selected, + ChipSetAction.selectNone => AIcons.unselected, // browsing - case ChipSetAction.search: - return AIcons.search; - case ChipSetAction.toggleTitleSearch: + ChipSetAction.search => AIcons.search, + ChipSetAction.toggleTitleSearch => // different data depending on toggle state - return AIcons.filter; - case ChipSetAction.createAlbum: - return AIcons.add; - case ChipSetAction.createVault: - return AIcons.vaultAdd; + AIcons.filter, + ChipSetAction.createAlbum => AIcons.add, + ChipSetAction.createVault => AIcons.vaultAdd, // browsing or selecting - case ChipSetAction.map: - return AIcons.map; - case ChipSetAction.slideshow: - return AIcons.slideshow; - case ChipSetAction.stats: - return AIcons.stats; + ChipSetAction.map => AIcons.map, + ChipSetAction.slideshow => AIcons.slideshow, + ChipSetAction.stats => AIcons.stats, // selecting (single/multiple filters) - case ChipSetAction.delete: - return AIcons.delete; - case ChipSetAction.hide: - return AIcons.hide; - case ChipSetAction.pin: - return AIcons.pin; - case ChipSetAction.unpin: - return AIcons.unpin; - case ChipSetAction.lockVault: - return AIcons.vaultLock; - case ChipSetAction.showCountryStates: - return AIcons.state; + ChipSetAction.delete => AIcons.delete, + ChipSetAction.hide => AIcons.hide, + ChipSetAction.pin => AIcons.pin, + ChipSetAction.unpin => AIcons.unpin, + ChipSetAction.lockVault => AIcons.vaultLock, + ChipSetAction.showCountryStates => AIcons.state, // selecting (single filter) - case ChipSetAction.rename: - return AIcons.name; - case ChipSetAction.setCover: - return AIcons.setCover; - case ChipSetAction.configureVault: - return AIcons.vaultConfigure; - } + ChipSetAction.rename => AIcons.name, + ChipSetAction.setCover => AIcons.setCover, + ChipSetAction.configureVault => AIcons.vaultConfigure, + }; } } diff --git a/lib/view/src/actions/entry.dart b/lib/view/src/actions/entry.dart index 960673705..356ce01cf 100644 --- a/lib/view/src/actions/entry.dart +++ b/lib/view/src/actions/entry.dart @@ -6,216 +6,137 @@ import 'package:flutter/widgets.dart'; extension ExtraEntryActionView on EntryAction { String getText(BuildContext context) { - switch (this) { - case EntryAction.info: - return context.l10n.entryActionInfo; - case EntryAction.addShortcut: - return context.l10n.collectionActionAddShortcut; - case EntryAction.copyToClipboard: - return context.l10n.entryActionCopyToClipboard; - case EntryAction.delete: - return context.l10n.entryActionDelete; - case EntryAction.restore: - return context.l10n.entryActionRestore; - case EntryAction.convert: - return context.l10n.entryActionConvert; - case EntryAction.print: - return context.l10n.entryActionPrint; - case EntryAction.rename: - return context.l10n.entryActionRename; - case EntryAction.copy: - return context.l10n.collectionActionCopy; - case EntryAction.move: - return context.l10n.collectionActionMove; - case EntryAction.share: - return context.l10n.entryActionShare; - case EntryAction.toggleFavourite: + final l10n = context.l10n; + return switch (this) { + EntryAction.info => l10n.entryActionInfo, + EntryAction.addShortcut => l10n.collectionActionAddShortcut, + EntryAction.copyToClipboard => l10n.entryActionCopyToClipboard, + EntryAction.delete => l10n.entryActionDelete, + EntryAction.restore => l10n.entryActionRestore, + EntryAction.convert => l10n.entryActionConvert, + EntryAction.print => l10n.entryActionPrint, + EntryAction.rename => l10n.entryActionRename, + EntryAction.copy => l10n.collectionActionCopy, + EntryAction.move => l10n.collectionActionMove, + EntryAction.share => l10n.entryActionShare, + EntryAction.toggleFavourite => // different data depending on toggle state - return context.l10n.entryActionAddFavourite; + l10n.entryActionAddFavourite, // raster - case EntryAction.rotateCCW: - return context.l10n.entryActionRotateCCW; - case EntryAction.rotateCW: - return context.l10n.entryActionRotateCW; - case EntryAction.flip: - return context.l10n.entryActionFlip; + EntryAction.rotateCCW => l10n.entryActionRotateCCW, + EntryAction.rotateCW => l10n.entryActionRotateCW, + EntryAction.flip => l10n.entryActionFlip, // vector - case EntryAction.viewSource: - return context.l10n.entryActionViewSource; + EntryAction.viewSource => l10n.entryActionViewSource, // video - case EntryAction.lockViewer: - return context.l10n.viewerActionLock; - case EntryAction.videoCaptureFrame: - return context.l10n.videoActionCaptureFrame; - case EntryAction.videoToggleMute: + EntryAction.lockViewer => l10n.viewerActionLock, + EntryAction.videoCaptureFrame => l10n.videoActionCaptureFrame, + EntryAction.videoToggleMute => // different data depending on toggle state - return context.l10n.videoActionMute; - case EntryAction.videoSelectStreams: - return context.l10n.videoActionSelectStreams; - case EntryAction.videoSetSpeed: - return context.l10n.videoActionSetSpeed; - case EntryAction.videoSettings: - return context.l10n.viewerActionSettings; - case EntryAction.videoTogglePlay: + l10n.videoActionMute, + EntryAction.videoSelectStreams => l10n.videoActionSelectStreams, + EntryAction.videoSetSpeed => l10n.videoActionSetSpeed, + EntryAction.videoSettings => l10n.viewerActionSettings, + EntryAction.videoTogglePlay => // different data depending on toggle state - return context.l10n.videoActionPlay; - case EntryAction.videoReplay10: - return context.l10n.videoActionReplay10; - case EntryAction.videoSkip10: - return context.l10n.videoActionSkip10; + l10n.videoActionPlay, + EntryAction.videoReplay10 => l10n.videoActionReplay10, + EntryAction.videoSkip10 => l10n.videoActionSkip10, // external - case EntryAction.edit: - return context.l10n.entryActionEdit; - case EntryAction.open: - case EntryAction.openVideo: - return context.l10n.entryActionOpen; - case EntryAction.openMap: - return context.l10n.entryActionOpenMap; - case EntryAction.setAs: - return context.l10n.entryActionSetAs; + EntryAction.edit => l10n.entryActionEdit, + EntryAction.open || EntryAction.openVideo => l10n.entryActionOpen, + EntryAction.openMap => l10n.entryActionOpenMap, + EntryAction.setAs => l10n.entryActionSetAs, // platform - case EntryAction.rotateScreen: - return context.l10n.entryActionRotateScreen; + EntryAction.rotateScreen => l10n.entryActionRotateScreen, // metadata - case EntryAction.editDate: - return context.l10n.entryInfoActionEditDate; - case EntryAction.editLocation: - return context.l10n.entryInfoActionEditLocation; - case EntryAction.editTitleDescription: - return context.l10n.entryInfoActionEditTitleDescription; - case EntryAction.editRating: - return context.l10n.entryInfoActionEditRating; - case EntryAction.editTags: - return context.l10n.entryInfoActionEditTags; - case EntryAction.removeMetadata: - return context.l10n.entryInfoActionRemoveMetadata; - case EntryAction.exportMetadata: - return context.l10n.entryInfoActionExportMetadata; + EntryAction.editDate => l10n.entryInfoActionEditDate, + EntryAction.editLocation => l10n.entryInfoActionEditLocation, + EntryAction.editTitleDescription => l10n.entryInfoActionEditTitleDescription, + EntryAction.editRating => l10n.entryInfoActionEditRating, + EntryAction.editTags => l10n.entryInfoActionEditTags, + EntryAction.removeMetadata => l10n.entryInfoActionRemoveMetadata, + EntryAction.exportMetadata => l10n.entryInfoActionExportMetadata, // metadata / GeoTIFF - case EntryAction.showGeoTiffOnMap: - return context.l10n.entryActionShowGeoTiffOnMap; + EntryAction.showGeoTiffOnMap => l10n.entryActionShowGeoTiffOnMap, // metadata / motion photo - case EntryAction.convertMotionPhotoToStillImage: - return context.l10n.entryActionConvertMotionPhotoToStillImage; - case EntryAction.viewMotionPhotoVideo: - return context.l10n.entryActionViewMotionPhotoVideo; + EntryAction.convertMotionPhotoToStillImage => l10n.entryActionConvertMotionPhotoToStillImage, + EntryAction.viewMotionPhotoVideo => l10n.entryActionViewMotionPhotoVideo, // debug - case EntryAction.debug: - return 'Debug'; - } + EntryAction.debug => 'Debug', + }; } Widget getIcon() { final child = Icon(getIconData()); - switch (this) { - case EntryAction.debug: - return ShaderMask( + return switch (this) { + EntryAction.debug => ShaderMask( shaderCallback: AvesColorsData.debugGradient.createShader, blendMode: BlendMode.srcIn, child: child, - ); - default: - return child; - } + ), + _ => child, + }; } IconData getIconData() { - switch (this) { - case EntryAction.info: - return AIcons.info; - case EntryAction.addShortcut: - return AIcons.addShortcut; - case EntryAction.copyToClipboard: - return AIcons.clipboard; - case EntryAction.delete: - return AIcons.delete; - case EntryAction.restore: - return AIcons.restore; - case EntryAction.convert: - return AIcons.convert; - case EntryAction.print: - return AIcons.print; - case EntryAction.rename: - return AIcons.name; - case EntryAction.copy: - return AIcons.copy; - case EntryAction.move: - return AIcons.move; - case EntryAction.share: - return AIcons.share; - case EntryAction.toggleFavourite: + return switch (this) { + EntryAction.info => AIcons.info, + EntryAction.addShortcut => AIcons.addShortcut, + EntryAction.copyToClipboard => AIcons.clipboard, + EntryAction.delete => AIcons.delete, + EntryAction.restore => AIcons.restore, + EntryAction.convert => AIcons.convert, + EntryAction.print => AIcons.print, + EntryAction.rename => AIcons.name, + EntryAction.copy => AIcons.copy, + EntryAction.move => AIcons.move, + EntryAction.share => AIcons.share, + EntryAction.toggleFavourite => // different data depending on toggle state - return AIcons.favourite; + AIcons.favourite, // raster - case EntryAction.rotateCCW: - return AIcons.rotateLeft; - case EntryAction.rotateCW: - return AIcons.rotateRight; - case EntryAction.flip: - return AIcons.flip; + EntryAction.rotateCCW => AIcons.rotateLeft, + EntryAction.rotateCW => AIcons.rotateRight, + EntryAction.flip => AIcons.flip, // vector - case EntryAction.viewSource: - return AIcons.vector; + EntryAction.viewSource => AIcons.vector, // video - case EntryAction.lockViewer: - return AIcons.viewerLock; - case EntryAction.videoCaptureFrame: - return AIcons.captureFrame; - case EntryAction.videoToggleMute: + EntryAction.lockViewer => AIcons.viewerLock, + EntryAction.videoCaptureFrame => AIcons.captureFrame, + EntryAction.videoToggleMute => // different data depending on toggle state - return AIcons.mute; - case EntryAction.videoSelectStreams: - return AIcons.streams; - case EntryAction.videoSetSpeed: - return AIcons.speed; - case EntryAction.videoSettings: - return AIcons.videoSettings; - case EntryAction.videoTogglePlay: + AIcons.mute, + EntryAction.videoSelectStreams => AIcons.streams, + EntryAction.videoSetSpeed => AIcons.speed, + EntryAction.videoSettings => AIcons.videoSettings, + EntryAction.videoTogglePlay => // different data depending on toggle state - return AIcons.play; - case EntryAction.videoReplay10: - return AIcons.replay10; - case EntryAction.videoSkip10: - return AIcons.skip10; + AIcons.play, + EntryAction.videoReplay10 => AIcons.replay10, + EntryAction.videoSkip10 => AIcons.skip10, // external - case EntryAction.edit: - return AIcons.edit; - case EntryAction.open: - case EntryAction.openVideo: - return AIcons.openOutside; - case EntryAction.openMap: - return AIcons.map; - case EntryAction.setAs: - return AIcons.setAs; + EntryAction.edit => AIcons.edit, + EntryAction.open || EntryAction.openVideo => AIcons.openOutside, + EntryAction.openMap => AIcons.map, + EntryAction.setAs => AIcons.setAs, // platform - case EntryAction.rotateScreen: - return AIcons.rotateScreen; + EntryAction.rotateScreen => AIcons.rotateScreen, // metadata - case EntryAction.editDate: - return AIcons.date; - case EntryAction.editLocation: - return AIcons.location; - case EntryAction.editTitleDescription: - return AIcons.description; - case EntryAction.editRating: - return AIcons.rating; - case EntryAction.editTags: - return AIcons.tag; - case EntryAction.removeMetadata: - return AIcons.clear; - case EntryAction.exportMetadata: - return AIcons.fileExport; + EntryAction.editDate => AIcons.date, + EntryAction.editLocation => AIcons.location, + EntryAction.editTitleDescription => AIcons.description, + EntryAction.editRating => AIcons.rating, + EntryAction.editTags => AIcons.tag, + EntryAction.removeMetadata => AIcons.clear, + EntryAction.exportMetadata => AIcons.fileExport, // metadata / GeoTIFF - case EntryAction.showGeoTiffOnMap: - return AIcons.map; + EntryAction.showGeoTiffOnMap => AIcons.map, // metadata / motion photo - case EntryAction.convertMotionPhotoToStillImage: - return AIcons.convertToStillImage; - case EntryAction.viewMotionPhotoVideo: - return AIcons.openVideo; + EntryAction.convertMotionPhotoToStillImage => AIcons.convertToStillImage, + EntryAction.viewMotionPhotoVideo => AIcons.openVideo, // debug - case EntryAction.debug: - return AIcons.debug; - } + EntryAction.debug => AIcons.debug, + }; } } diff --git a/lib/view/src/actions/entry_set.dart b/lib/view/src/actions/entry_set.dart index 880250bc6..9fb163be7 100644 --- a/lib/view/src/actions/entry_set.dart +++ b/lib/view/src/actions/entry_set.dart @@ -5,142 +5,88 @@ import 'package:flutter/material.dart'; extension ExtraEntrySetActionView on EntrySetAction { String getText(BuildContext context) { - switch (this) { + return switch (this) { // general - case EntrySetAction.configureView: - return context.l10n.menuActionConfigureView; - case EntrySetAction.select: - return context.l10n.menuActionSelect; - case EntrySetAction.selectAll: - return context.l10n.menuActionSelectAll; - case EntrySetAction.selectNone: - return context.l10n.menuActionSelectNone; + EntrySetAction.configureView => context.l10n.menuActionConfigureView, + EntrySetAction.select => context.l10n.menuActionSelect, + EntrySetAction.selectAll => context.l10n.menuActionSelectAll, + EntrySetAction.selectNone => context.l10n.menuActionSelectNone, // browsing - case EntrySetAction.searchCollection: - return MaterialLocalizations.of(context).searchFieldLabel; - case EntrySetAction.toggleTitleSearch: + EntrySetAction.searchCollection => MaterialLocalizations.of(context).searchFieldLabel, + EntrySetAction.toggleTitleSearch => // different data depending on toggle state - return context.l10n.collectionActionShowTitleSearch; - case EntrySetAction.addShortcut: - return context.l10n.collectionActionAddShortcut; - case EntrySetAction.emptyBin: - return context.l10n.collectionActionEmptyBin; + context.l10n.collectionActionShowTitleSearch, + EntrySetAction.addShortcut => context.l10n.collectionActionAddShortcut, + EntrySetAction.emptyBin => context.l10n.collectionActionEmptyBin, // browsing or selecting - case EntrySetAction.map: - return context.l10n.menuActionMap; - case EntrySetAction.slideshow: - return context.l10n.menuActionSlideshow; - case EntrySetAction.stats: - return context.l10n.menuActionStats; - case EntrySetAction.rescan: - return context.l10n.collectionActionRescan; + EntrySetAction.map => context.l10n.menuActionMap, + EntrySetAction.slideshow => context.l10n.menuActionSlideshow, + EntrySetAction.stats => context.l10n.menuActionStats, + EntrySetAction.rescan => context.l10n.collectionActionRescan, // selecting - case EntrySetAction.share: - return context.l10n.entryActionShare; - case EntrySetAction.delete: - return context.l10n.entryActionDelete; - case EntrySetAction.restore: - return context.l10n.entryActionRestore; - case EntrySetAction.copy: - return context.l10n.collectionActionCopy; - case EntrySetAction.move: - return context.l10n.collectionActionMove; - case EntrySetAction.rename: - return context.l10n.entryActionRename; - case EntrySetAction.convert: - return context.l10n.entryActionConvert; - case EntrySetAction.toggleFavourite: + EntrySetAction.share => context.l10n.entryActionShare, + EntrySetAction.delete => context.l10n.entryActionDelete, + EntrySetAction.restore => context.l10n.entryActionRestore, + EntrySetAction.copy => context.l10n.collectionActionCopy, + EntrySetAction.move => context.l10n.collectionActionMove, + EntrySetAction.rename => context.l10n.entryActionRename, + EntrySetAction.convert => context.l10n.entryActionConvert, + EntrySetAction.toggleFavourite => // different data depending on toggle state - return context.l10n.entryActionAddFavourite; - case EntrySetAction.rotateCCW: - return context.l10n.entryActionRotateCCW; - case EntrySetAction.rotateCW: - return context.l10n.entryActionRotateCW; - case EntrySetAction.flip: - return context.l10n.entryActionFlip; - case EntrySetAction.editDate: - return context.l10n.entryInfoActionEditDate; - case EntrySetAction.editLocation: - return context.l10n.entryInfoActionEditLocation; - case EntrySetAction.editTitleDescription: - return context.l10n.entryInfoActionEditTitleDescription; - case EntrySetAction.editRating: - return context.l10n.entryInfoActionEditRating; - case EntrySetAction.editTags: - return context.l10n.entryInfoActionEditTags; - case EntrySetAction.removeMetadata: - return context.l10n.entryInfoActionRemoveMetadata; - } + context.l10n.entryActionAddFavourite, + EntrySetAction.rotateCCW => context.l10n.entryActionRotateCCW, + EntrySetAction.rotateCW => context.l10n.entryActionRotateCW, + EntrySetAction.flip => context.l10n.entryActionFlip, + EntrySetAction.editDate => context.l10n.entryInfoActionEditDate, + EntrySetAction.editLocation => context.l10n.entryInfoActionEditLocation, + EntrySetAction.editTitleDescription => context.l10n.entryInfoActionEditTitleDescription, + EntrySetAction.editRating => context.l10n.entryInfoActionEditRating, + EntrySetAction.editTags => context.l10n.entryInfoActionEditTags, + EntrySetAction.removeMetadata => context.l10n.entryInfoActionRemoveMetadata, + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { + return switch (this) { // general - case EntrySetAction.configureView: - return AIcons.view; - case EntrySetAction.select: - return AIcons.select; - case EntrySetAction.selectAll: - return AIcons.selected; - case EntrySetAction.selectNone: - return AIcons.unselected; + EntrySetAction.configureView => AIcons.view, + EntrySetAction.select => AIcons.select, + EntrySetAction.selectAll => AIcons.selected, + EntrySetAction.selectNone => AIcons.unselected, // browsing - case EntrySetAction.searchCollection: - return AIcons.search; - case EntrySetAction.toggleTitleSearch: + EntrySetAction.searchCollection => AIcons.search, + EntrySetAction.toggleTitleSearch => // different data depending on toggle state - return AIcons.filter; - case EntrySetAction.addShortcut: - return AIcons.addShortcut; - case EntrySetAction.emptyBin: - return AIcons.emptyBin; + AIcons.filter, + EntrySetAction.addShortcut => AIcons.addShortcut, + EntrySetAction.emptyBin => AIcons.emptyBin, // browsing or selecting - case EntrySetAction.map: - return AIcons.map; - case EntrySetAction.slideshow: - return AIcons.slideshow; - case EntrySetAction.stats: - return AIcons.stats; - case EntrySetAction.rescan: - return AIcons.refresh; + EntrySetAction.map => AIcons.map, + EntrySetAction.slideshow => AIcons.slideshow, + EntrySetAction.stats => AIcons.stats, + EntrySetAction.rescan => AIcons.refresh, // selecting - case EntrySetAction.share: - return AIcons.share; - case EntrySetAction.delete: - return AIcons.delete; - case EntrySetAction.restore: - return AIcons.restore; - case EntrySetAction.copy: - return AIcons.copy; - case EntrySetAction.move: - return AIcons.move; - case EntrySetAction.rename: - return AIcons.name; - case EntrySetAction.convert: - return AIcons.convert; - case EntrySetAction.toggleFavourite: + EntrySetAction.share => AIcons.share, + EntrySetAction.delete => AIcons.delete, + EntrySetAction.restore => AIcons.restore, + EntrySetAction.copy => AIcons.copy, + EntrySetAction.move => AIcons.move, + EntrySetAction.rename => AIcons.name, + EntrySetAction.convert => AIcons.convert, + EntrySetAction.toggleFavourite => // different data depending on toggle state - return AIcons.favourite; - case EntrySetAction.rotateCCW: - return AIcons.rotateLeft; - case EntrySetAction.rotateCW: - return AIcons.rotateRight; - case EntrySetAction.flip: - return AIcons.flip; - case EntrySetAction.editDate: - return AIcons.date; - case EntrySetAction.editLocation: - return AIcons.location; - case EntrySetAction.editTitleDescription: - return AIcons.description; - case EntrySetAction.editRating: - return AIcons.rating; - case EntrySetAction.editTags: - return AIcons.tag; - case EntrySetAction.removeMetadata: - return AIcons.clear; - } + AIcons.favourite, + EntrySetAction.rotateCCW => AIcons.rotateLeft, + EntrySetAction.rotateCW => AIcons.rotateRight, + EntrySetAction.flip => AIcons.flip, + EntrySetAction.editDate => AIcons.date, + EntrySetAction.editLocation => AIcons.location, + EntrySetAction.editTitleDescription => AIcons.description, + EntrySetAction.editRating => AIcons.rating, + EntrySetAction.editTags => AIcons.tag, + EntrySetAction.removeMetadata => AIcons.clear, + }; } } diff --git a/lib/view/src/actions/map.dart b/lib/view/src/actions/map.dart index 05a2ceb71..ee7db32fc 100644 --- a/lib/view/src/actions/map.dart +++ b/lib/view/src/actions/map.dart @@ -5,26 +5,21 @@ import 'package:flutter/widgets.dart'; extension ExtraMapActionView on MapAction { String getText(BuildContext context) { - switch (this) { - case MapAction.selectStyle: - return context.l10n.mapStyleTooltip; - case MapAction.zoomIn: - return context.l10n.mapZoomInTooltip; - case MapAction.zoomOut: - return context.l10n.mapZoomOutTooltip; - } + final l10n = context.l10n; + return switch (this) { + MapAction.selectStyle => l10n.mapStyleTooltip, + MapAction.zoomIn => l10n.mapZoomInTooltip, + MapAction.zoomOut => l10n.mapZoomOutTooltip, + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { - case MapAction.selectStyle: - return AIcons.layers; - case MapAction.zoomIn: - return AIcons.zoomIn; - case MapAction.zoomOut: - return AIcons.zoomOut; - } + return switch (this) { + MapAction.selectStyle => AIcons.layers, + MapAction.zoomIn => AIcons.zoomIn, + MapAction.zoomOut => AIcons.zoomOut, + }; } } diff --git a/lib/view/src/actions/map_cluster.dart b/lib/view/src/actions/map_cluster.dart index cc605675f..cf016797c 100644 --- a/lib/view/src/actions/map_cluster.dart +++ b/lib/view/src/actions/map_cluster.dart @@ -5,22 +5,19 @@ import 'package:flutter/widgets.dart'; extension ExtraMapClusterActionView on MapClusterAction { String getText(BuildContext context) { - switch (this) { - case MapClusterAction.editLocation: - return context.l10n.entryInfoActionEditLocation; - case MapClusterAction.removeLocation: - return context.l10n.entryInfoActionRemoveLocation; - } + final l10n = context.l10n; + return switch (this) { + MapClusterAction.editLocation => l10n.entryInfoActionEditLocation, + MapClusterAction.removeLocation => l10n.entryInfoActionRemoveLocation, + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { - case MapClusterAction.editLocation: - return AIcons.edit; - case MapClusterAction.removeLocation: - return AIcons.clear; - } + return switch (this) { + MapClusterAction.editLocation => AIcons.edit, + MapClusterAction.removeLocation => AIcons.clear, + }; } } diff --git a/lib/view/src/actions/share.dart b/lib/view/src/actions/share.dart index d9a224a00..fd1042e7d 100644 --- a/lib/view/src/actions/share.dart +++ b/lib/view/src/actions/share.dart @@ -5,22 +5,19 @@ import 'package:flutter/widgets.dart'; extension ExtraShareActionView on ShareAction { String getText(BuildContext context) { - switch (this) { - case ShareAction.imageOnly: - return context.l10n.entryActionShareImageOnly; - case ShareAction.videoOnly: - return context.l10n.entryActionShareVideoOnly; - } + final l10n = context.l10n; + return switch (this) { + ShareAction.imageOnly => l10n.entryActionShareImageOnly, + ShareAction.videoOnly => l10n.entryActionShareVideoOnly, + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { - case ShareAction.imageOnly: - return AIcons.image; - case ShareAction.videoOnly: - return AIcons.video; - } + return switch (this) { + ShareAction.imageOnly => AIcons.image, + ShareAction.videoOnly => AIcons.video, + }; } } diff --git a/lib/view/src/actions/slideshow.dart b/lib/view/src/actions/slideshow.dart index 84c729bad..69635df33 100644 --- a/lib/view/src/actions/slideshow.dart +++ b/lib/view/src/actions/slideshow.dart @@ -5,26 +5,21 @@ import 'package:flutter/widgets.dart'; extension ExtraSlideshowActionView on SlideshowAction { String getText(BuildContext context) { - switch (this) { - case SlideshowAction.resume: - return context.l10n.slideshowActionResume; - case SlideshowAction.showInCollection: - return context.l10n.slideshowActionShowInCollection; - case SlideshowAction.settings: - return context.l10n.viewerActionSettings; - } + final l10n = context.l10n; + return switch (this) { + SlideshowAction.resume => l10n.slideshowActionResume, + SlideshowAction.showInCollection => l10n.slideshowActionShowInCollection, + SlideshowAction.settings => l10n.viewerActionSettings, + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { - case SlideshowAction.resume: - return AIcons.play; - case SlideshowAction.showInCollection: - return AIcons.allCollection; - case SlideshowAction.settings: - return AIcons.settings; - } + return switch (this) { + SlideshowAction.resume => AIcons.play, + SlideshowAction.showInCollection => AIcons.allCollection, + SlideshowAction.settings => AIcons.settings, + }; } } diff --git a/lib/view/src/editor/enums.dart b/lib/view/src/editor/enums.dart index 43b9fe95d..13282f8a8 100644 --- a/lib/view/src/editor/enums.dart +++ b/lib/view/src/editor/enums.dart @@ -6,52 +6,42 @@ import 'package:flutter/widgets.dart'; extension ExtraEditorActionView on EditorAction { String getText(BuildContext context) { - switch (this) { - case EditorAction.transform: - return context.l10n.editorActionTransform; - } + final l10n = context.l10n; + return switch (this) { + EditorAction.transform => l10n.editorActionTransform, + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { - case EditorAction.transform: - return AIcons.transform; - } + return switch (this) { + EditorAction.transform => AIcons.transform, + }; } } extension ExtraCropAspectRatioView on CropAspectRatio { String getText(BuildContext context) { - switch (this) { - case CropAspectRatio.free: - return context.l10n.cropAspectRatioFree; - case CropAspectRatio.original: - return context.l10n.cropAspectRatioOriginal; - case CropAspectRatio.square: - return context.l10n.cropAspectRatioSquare; - case CropAspectRatio.ar_16_9: - return '16${UniChars.ratio}9'; - case CropAspectRatio.ar_4_3: - return '4${UniChars.ratio}3'; - } + final l10n = context.l10n; + return switch (this) { + CropAspectRatio.free => l10n.cropAspectRatioFree, + CropAspectRatio.original => l10n.cropAspectRatioOriginal, + CropAspectRatio.square => l10n.cropAspectRatioSquare, + CropAspectRatio.ar_16_9 => '16${UniChars.ratio}9', + CropAspectRatio.ar_4_3 => '4${UniChars.ratio}3', + }; } Widget getIcon() => Icon(_getIconData()); IconData _getIconData() { - switch (this) { - case CropAspectRatio.free: - return AIcons.aspectRatioFree; - case CropAspectRatio.original: - return AIcons.aspectRatioOriginal; - case CropAspectRatio.square: - return AIcons.aspectRatioSquare; - case CropAspectRatio.ar_16_9: - return AIcons.aspectRatio_16_9; - case CropAspectRatio.ar_4_3: - return AIcons.aspectRatio_4_3; - } + return switch (this) { + CropAspectRatio.free => AIcons.aspectRatioFree, + CropAspectRatio.original => AIcons.aspectRatioOriginal, + CropAspectRatio.square => AIcons.aspectRatioSquare, + CropAspectRatio.ar_16_9 => AIcons.aspectRatio_16_9, + CropAspectRatio.ar_4_3 => AIcons.aspectRatio_4_3, + }; } } diff --git a/lib/view/src/metadata/date_edit_action.dart b/lib/view/src/metadata/date_edit_action.dart index de735ff63..6b9005483 100644 --- a/lib/view/src/metadata/date_edit_action.dart +++ b/lib/view/src/metadata/date_edit_action.dart @@ -4,19 +4,14 @@ import 'package:flutter/widgets.dart'; extension ExtraDateEditActionView on DateEditAction { String getText(BuildContext context) { - switch (this) { - case DateEditAction.setCustom: - return context.l10n.editEntryDateDialogSetCustom; - case DateEditAction.copyField: - return context.l10n.editEntryDateDialogCopyField; - case DateEditAction.copyItem: - return context.l10n.editEntryDialogCopyFromItem; - case DateEditAction.extractFromTitle: - return context.l10n.editEntryDateDialogExtractFromTitle; - case DateEditAction.shift: - return context.l10n.editEntryDateDialogShift; - case DateEditAction.remove: - return context.l10n.actionRemove; - } + final l10n = context.l10n; + return switch (this) { + DateEditAction.setCustom => l10n.editEntryDateDialogSetCustom, + DateEditAction.copyField => l10n.editEntryDateDialogCopyField, + DateEditAction.copyItem => l10n.editEntryDialogCopyFromItem, + DateEditAction.extractFromTitle => l10n.editEntryDateDialogExtractFromTitle, + DateEditAction.shift => l10n.editEntryDateDialogShift, + DateEditAction.remove => l10n.actionRemove, + }; } } diff --git a/lib/view/src/metadata/date_field_source.dart b/lib/view/src/metadata/date_field_source.dart index 88355826b..ccb58d841 100644 --- a/lib/view/src/metadata/date_field_source.dart +++ b/lib/view/src/metadata/date_field_source.dart @@ -4,17 +4,12 @@ import 'package:flutter/widgets.dart'; extension ExtraDateFieldSourceView on DateFieldSource { String getText(BuildContext context) { - switch (this) { - case DateFieldSource.fileModifiedDate: - return context.l10n.editEntryDateDialogSourceFileModifiedDate; - case DateFieldSource.exifDate: - return 'Exif date'; - case DateFieldSource.exifDateOriginal: - return 'Exif original date'; - case DateFieldSource.exifDateDigitized: - return 'Exif digitized date'; - case DateFieldSource.exifGpsDate: - return 'Exif GPS date'; - } + return switch (this) { + DateFieldSource.fileModifiedDate => context.l10n.editEntryDateDialogSourceFileModifiedDate, + DateFieldSource.exifDate => 'Exif date', + DateFieldSource.exifDateOriginal => 'Exif original date', + DateFieldSource.exifDateDigitized => 'Exif digitized date', + DateFieldSource.exifGpsDate => 'Exif GPS date', + }; } } diff --git a/lib/view/src/metadata/length_unit.dart b/lib/view/src/metadata/length_unit.dart index d4766d902..2ec818db3 100644 --- a/lib/view/src/metadata/length_unit.dart +++ b/lib/view/src/metadata/length_unit.dart @@ -4,11 +4,10 @@ import 'package:flutter/widgets.dart'; extension ExtraLengthUnitView on LengthUnit { String getText(BuildContext context) { - switch (this) { - case LengthUnit.px: - return context.l10n.lengthUnitPixel; - case LengthUnit.percent: - return context.l10n.lengthUnitPercent; - } + final l10n = context.l10n; + return switch (this) { + LengthUnit.px => l10n.lengthUnitPixel, + LengthUnit.percent => l10n.lengthUnitPercent, + }; } } diff --git a/lib/view/src/metadata/location_edit_action.dart b/lib/view/src/metadata/location_edit_action.dart index 469a15c3d..ad8b54004 100644 --- a/lib/view/src/metadata/location_edit_action.dart +++ b/lib/view/src/metadata/location_edit_action.dart @@ -4,15 +4,12 @@ import 'package:flutter/widgets.dart'; extension ExtraLocationEditActionView on LocationEditAction { String getText(BuildContext context) { - switch (this) { - case LocationEditAction.chooseOnMap: - return context.l10n.editEntryLocationDialogChooseOnMap; - case LocationEditAction.copyItem: - return context.l10n.editEntryDialogCopyFromItem; - case LocationEditAction.setCustom: - return context.l10n.editEntryLocationDialogSetCustom; - case LocationEditAction.remove: - return context.l10n.actionRemove; - } + final l10n = context.l10n; + return switch (this) { + LocationEditAction.chooseOnMap => l10n.editEntryLocationDialogChooseOnMap, + LocationEditAction.copyItem => l10n.editEntryDialogCopyFromItem, + LocationEditAction.setCustom => l10n.editEntryLocationDialogSetCustom, + LocationEditAction.remove => l10n.actionRemove, + }; } } diff --git a/lib/view/src/metadata/metadata_type.dart b/lib/view/src/metadata/metadata_type.dart index 5eee2bf45..33b085901 100644 --- a/lib/view/src/metadata/metadata_type.dart +++ b/lib/view/src/metadata/metadata_type.dart @@ -3,27 +3,17 @@ import 'package:aves_model/aves_model.dart'; extension ExtraMetadataTypeView on MetadataType { // match `metadata-extractor` directory names String getText() { - switch (this) { - case MetadataType.comment: - return 'Comment'; - case MetadataType.exif: - return 'Exif'; - case MetadataType.iccProfile: - return 'ICC Profile'; - case MetadataType.iptc: - return 'IPTC'; - case MetadataType.jfif: - return 'JFIF'; - case MetadataType.jpegAdobe: - return 'Adobe JPEG'; - case MetadataType.jpegDucky: - return 'Ducky'; - case MetadataType.mp4: - return 'MP4'; - case MetadataType.photoshopIrb: - return 'Photoshop'; - case MetadataType.xmp: - return 'XMP'; - } + return switch (this) { + MetadataType.comment => 'Comment', + MetadataType.exif => 'Exif', + MetadataType.iccProfile => 'ICC Profile', + MetadataType.iptc => 'IPTC', + MetadataType.jfif => 'JFIF', + MetadataType.jpegAdobe => 'Adobe JPEG', + MetadataType.jpegDucky => 'Ducky', + MetadataType.mp4 => 'MP4', + MetadataType.photoshopIrb => 'Photoshop', + MetadataType.xmp => 'XMP', + }; } } diff --git a/lib/view/src/source/album.dart b/lib/view/src/source/album.dart index 5706431dc..2ac79467a 100644 --- a/lib/view/src/source/album.dart +++ b/lib/view/src/source/album.dart @@ -4,21 +4,14 @@ import 'package:flutter/widgets.dart'; extension ExtraAlbumTypeView on AlbumType { String? getName(BuildContext context) { - switch (this) { - case AlbumType.camera: - return context.l10n.albumCamera; - case AlbumType.download: - return context.l10n.albumDownload; - case AlbumType.screenshots: - return context.l10n.albumScreenshots; - case AlbumType.screenRecordings: - return context.l10n.albumScreenRecordings; - case AlbumType.videoCaptures: - return context.l10n.albumVideoCaptures; - case AlbumType.regular: - case AlbumType.vault: - case AlbumType.app: - return null; - } + final l10n = context.l10n; + return switch (this) { + AlbumType.camera => l10n.albumCamera, + AlbumType.download => l10n.albumDownload, + AlbumType.screenshots => l10n.albumScreenshots, + AlbumType.screenRecordings => l10n.albumScreenRecordings, + AlbumType.videoCaptures => l10n.albumVideoCaptures, + AlbumType.regular || AlbumType.vault || AlbumType.app => null, + }; } } diff --git a/lib/view/src/source/state.dart b/lib/view/src/source/state.dart index 7b23db094..9adc287d1 100644 --- a/lib/view/src/source/state.dart +++ b/lib/view/src/source/state.dart @@ -3,17 +3,12 @@ import 'package:aves_model/aves_model.dart'; extension ExtraSourceStateView on SourceState { String? getName(AppLocalizations l10n) { - switch (this) { - case SourceState.loading: - return l10n.sourceStateLoading; - case SourceState.cataloguing: - return l10n.sourceStateCataloguing; - case SourceState.locatingCountries: - return l10n.sourceStateLocatingCountries; - case SourceState.locatingPlaces: - return l10n.sourceStateLocatingPlaces; - case SourceState.ready: - return null; - } + return switch (this) { + SourceState.loading => l10n.sourceStateLoading, + SourceState.cataloguing => l10n.sourceStateCataloguing, + SourceState.locatingCountries => l10n.sourceStateLocatingCountries, + SourceState.locatingPlaces => l10n.sourceStateLocatingPlaces, + SourceState.ready => null, + }; } } diff --git a/lib/view/src/source/vault.dart b/lib/view/src/source/vault.dart index e72b42ad9..10c9ad16a 100644 --- a/lib/view/src/source/vault.dart +++ b/lib/view/src/source/vault.dart @@ -4,15 +4,12 @@ import 'package:flutter/widgets.dart'; extension ExtraVaultLockTypeView on VaultLockType { String getText(BuildContext context) { - switch (this) { - case VaultLockType.system: - return context.l10n.settingsSystemDefault; - case VaultLockType.pattern: - return context.l10n.vaultLockTypePattern; - case VaultLockType.pin: - return context.l10n.vaultLockTypePin; - case VaultLockType.password: - return context.l10n.vaultLockTypePassword; - } + final l10n = context.l10n; + return switch (this) { + VaultLockType.system => l10n.settingsSystemDefault, + VaultLockType.pattern => l10n.vaultLockTypePattern, + VaultLockType.pin => l10n.vaultLockTypePin, + VaultLockType.password => l10n.vaultLockTypePassword, + }; } } diff --git a/lib/widgets/common/behaviour/pop/tv_navigation.dart b/lib/widgets/common/behaviour/pop/tv_navigation.dart index e51367139..a8a5250ba 100644 --- a/lib/widgets/common/behaviour/pop/tv_navigation.dart +++ b/lib/widgets/common/behaviour/pop/tv_navigation.dart @@ -30,13 +30,10 @@ class TvNavigationPopHandler { if (currentRoute != homePage.routeName) return false; - switch (homePage) { - case HomePageSetting.collection: - return context.read().filters.isEmpty; - case HomePageSetting.albums: - case HomePageSetting.tags: - return true; - } + return switch (homePage) { + HomePageSetting.collection => context.read().filters.isEmpty, + HomePageSetting.albums || HomePageSetting.tags => true, + }; } static Route _getHomeRoute() { @@ -46,13 +43,10 @@ class TvNavigationPopHandler { builder: builder, ); - switch (homePage) { - case HomePageSetting.collection: - return buildRoute((context) => CollectionPage(source: context.read(), filters: null)); - case HomePageSetting.albums: - return buildRoute((context) => const AlbumListPage()); - case HomePageSetting.tags: - return buildRoute((context) => const TagListPage()); - } + return switch (homePage) { + HomePageSetting.collection => buildRoute((context) => CollectionPage(source: context.read(), filters: null)), + HomePageSetting.albums => buildRoute((context) => const AlbumListPage()), + HomePageSetting.tags => buildRoute((context) => const TagListPage()), + }; } } diff --git a/lib/widgets/dialogs/entry_editors/edit_description_dialog.dart b/lib/widgets/dialogs/entry_editors/edit_description_dialog.dart index e60e49cae..239885316 100644 --- a/lib/widgets/dialogs/entry_editors/edit_description_dialog.dart +++ b/lib/widgets/dialogs/entry_editors/edit_description_dialog.dart @@ -92,12 +92,11 @@ class _EditEntryTitleDescriptionDialogState extends State l10n.viewerInfoLabelTitle, + DescriptionField.description => l10n.viewerInfoLabelDescription, + }; } void _submit(BuildContext context) { diff --git a/lib/widgets/dialogs/pick_dialogs/album_pick_page.dart b/lib/widgets/dialogs/pick_dialogs/album_pick_page.dart index 56082c3e8..3771a14df 100644 --- a/lib/widgets/dialogs/pick_dialogs/album_pick_page.dart +++ b/lib/widgets/dialogs/pick_dialogs/album_pick_page.dart @@ -68,18 +68,13 @@ class _AlbumPickPageState extends State<_AlbumPickPage> { CollectionSource get source => widget.source; String get title { - switch (widget.moveType) { - case MoveType.copy: - return context.l10n.albumPickPageTitleCopy; - case MoveType.move: - return context.l10n.albumPickPageTitleMove; - case MoveType.export: - return context.l10n.albumPickPageTitleExport; - case MoveType.toBin: - case MoveType.fromBin: - case null: - return context.l10n.albumPickPageTitlePick; - } + final l10n = context.l10n; + return switch (widget.moveType) { + MoveType.copy => l10n.albumPickPageTitleCopy, + MoveType.move => l10n.albumPickPageTitleMove, + MoveType.export => l10n.albumPickPageTitleExport, + MoveType.toBin || MoveType.fromBin || null => l10n.albumPickPageTitlePick, + }; } static const _quickActions = [ diff --git a/lib/widgets/filter_grids/common/enums.dart b/lib/widgets/filter_grids/common/enums.dart index 0113ecfca..e132044ad 100644 --- a/lib/widgets/filter_grids/common/enums.dart +++ b/lib/widgets/filter_grids/common/enums.dart @@ -6,37 +6,26 @@ enum AlbumImportance { newAlbum, pinned, special, apps, vaults, regular } extension ExtraAlbumImportance on AlbumImportance { String getText(BuildContext context) { - switch (this) { - case AlbumImportance.newAlbum: - return context.l10n.albumTierNew; - case AlbumImportance.pinned: - return context.l10n.albumTierPinned; - case AlbumImportance.special: - return context.l10n.albumTierSpecial; - case AlbumImportance.apps: - return context.l10n.albumTierApps; - case AlbumImportance.vaults: - return context.l10n.albumTierVaults; - case AlbumImportance.regular: - return context.l10n.albumTierRegular; - } + final l10n = context.l10n; + return switch (this) { + AlbumImportance.newAlbum => l10n.albumTierNew, + AlbumImportance.pinned => l10n.albumTierPinned, + AlbumImportance.special => l10n.albumTierSpecial, + AlbumImportance.apps => l10n.albumTierApps, + AlbumImportance.vaults => l10n.albumTierVaults, + AlbumImportance.regular => l10n.albumTierRegular, + }; } IconData getIcon() { - switch (this) { - case AlbumImportance.newAlbum: - return AIcons.newTier; - case AlbumImportance.pinned: - return AIcons.pin; - case AlbumImportance.special: - return AIcons.important; - case AlbumImportance.apps: - return AIcons.app; - case AlbumImportance.vaults: - return AIcons.locked; - case AlbumImportance.regular: - return AIcons.album; - } + return switch (this) { + AlbumImportance.newAlbum => AIcons.newTier, + AlbumImportance.pinned => AIcons.pin, + AlbumImportance.special => AIcons.important, + AlbumImportance.apps => AIcons.app, + AlbumImportance.vaults => AIcons.locked, + AlbumImportance.regular => AIcons.album, + }; } } @@ -44,24 +33,19 @@ enum AlbumMimeType { images, videos, mixed } extension ExtraAlbumMimeType on AlbumMimeType { String getText(BuildContext context) { - switch (this) { - case AlbumMimeType.images: - return context.l10n.drawerCollectionImages; - case AlbumMimeType.videos: - return context.l10n.drawerCollectionVideos; - case AlbumMimeType.mixed: - return context.l10n.albumMimeTypeMixed; - } + final l10n = context.l10n; + return switch (this) { + AlbumMimeType.images => l10n.drawerCollectionImages, + AlbumMimeType.videos => l10n.drawerCollectionVideos, + AlbumMimeType.mixed => l10n.albumMimeTypeMixed, + }; } IconData getIcon() { - switch (this) { - case AlbumMimeType.images: - return AIcons.image; - case AlbumMimeType.videos: - return AIcons.video; - case AlbumMimeType.mixed: - return AIcons.mimeType; - } + return switch (this) { + AlbumMimeType.images => AIcons.image, + AlbumMimeType.videos => AIcons.video, + AlbumMimeType.mixed => AIcons.mimeType, + }; } } diff --git a/lib/widgets/settings/app_export/items.dart b/lib/widgets/settings/app_export/items.dart index 5ee21faa5..ac5f20eb3 100644 --- a/lib/widgets/settings/app_export/items.dart +++ b/lib/widgets/settings/app_export/items.dart @@ -9,25 +9,20 @@ enum AppExportItem { covers, favourites, settings } extension ExtraAppExportItem on AppExportItem { String getText(BuildContext context) { - switch (this) { - case AppExportItem.covers: - return context.l10n.appExportCovers; - case AppExportItem.favourites: - return context.l10n.appExportFavourites; - case AppExportItem.settings: - return context.l10n.appExportSettings; - } + final l10n = context.l10n; + return switch (this) { + AppExportItem.covers => l10n.appExportCovers, + AppExportItem.favourites => l10n.appExportFavourites, + AppExportItem.settings => l10n.appExportSettings, + }; } dynamic export(CollectionSource source) { - switch (this) { - case AppExportItem.covers: - return covers.export(source); - case AppExportItem.favourites: - return favourites.export(source); - case AppExportItem.settings: - return settings.export(); - } + return switch (this) { + AppExportItem.covers => covers.export(source), + AppExportItem.favourites => favourites.export(source), + AppExportItem.settings => settings.export(), + }; } Future import(dynamic jsonMap, CollectionSource source) async { diff --git a/lib/widgets/settings/video/subtitle_theme.dart b/lib/widgets/settings/video/subtitle_theme.dart index 4d7857736..6758d9437 100644 --- a/lib/widgets/settings/video/subtitle_theme.dart +++ b/lib/widgets/settings/video/subtitle_theme.dart @@ -97,15 +97,12 @@ class SubtitleThemePage extends StatelessWidget { } String _getTextAlignName(BuildContext context, TextAlign align) { - switch (align) { - case TextAlign.left: - return context.l10n.settingsSubtitleThemeTextAlignmentLeft; - case TextAlign.center: - return context.l10n.settingsSubtitleThemeTextAlignmentCenter; - case TextAlign.right: - return context.l10n.settingsSubtitleThemeTextAlignmentRight; - default: - return ''; - } + final l10n = context.l10n; + return switch (align) { + TextAlign.left => l10n.settingsSubtitleThemeTextAlignmentLeft, + TextAlign.center => l10n.settingsSubtitleThemeTextAlignmentCenter, + TextAlign.right => l10n.settingsSubtitleThemeTextAlignmentRight, + _ => '', + }; } } diff --git a/untranslated.json b/untranslated.json index 0eb149fa3..d9b1843f7 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1678,20 +1678,6 @@ "settingsViewerShowHistogram" ], - "es": [ - "overlayHistogramNone", - "overlayHistogramRGB", - "overlayHistogramLuminance", - "settingsViewerShowHistogram" - ], - - "eu": [ - "overlayHistogramNone", - "overlayHistogramRGB", - "overlayHistogramLuminance", - "settingsViewerShowHistogram" - ], - "fa": [ "saveCopyButtonLabel", "applyTooltip", @@ -2207,13 +2193,6 @@ "filePickerUseThisFolder" ], - "fr": [ - "overlayHistogramNone", - "overlayHistogramRGB", - "overlayHistogramLuminance", - "settingsViewerShowHistogram" - ], - "gl": [ "columnCount", "saveCopyButtonLabel", @@ -4100,13 +4079,6 @@ "settingsViewerShowHistogram" ], - "id": [ - "overlayHistogramNone", - "overlayHistogramRGB", - "overlayHistogramLuminance", - "settingsViewerShowHistogram" - ], - "it": [ "overlayHistogramNone", "overlayHistogramRGB", @@ -4825,13 +4797,6 @@ "filePickerUseThisFolder" ], - "ko": [ - "overlayHistogramNone", - "overlayHistogramRGB", - "overlayHistogramLuminance", - "settingsViewerShowHistogram" - ], - "lt": [ "columnCount", "saveCopyButtonLabel", @@ -6235,53 +6200,23 @@ ], "nb": [ - "saveCopyButtonLabel", - "applyTooltip", - "chipActionShowCountryStates", "viewerActionLock", "viewerActionUnlock", "editorActionTransform", - "editorTransformCrop", - "editorTransformRotate", "cropAspectRatioFree", "cropAspectRatioOriginal", "cropAspectRatioSquare", - "maxBrightnessNever", - "maxBrightnessAlways", "overlayHistogramNone", - "overlayHistogramRGB", "overlayHistogramLuminance", - "vaultLockTypePattern", "settingsVideoEnablePip", - "videoResumptionModeNever", - "videoResumptionModeAlways", "widgetTapUpdateWidget", "patternDialogEnter", - "patternDialogConfirm", - "exportEntryDialogQuality", - "aboutDataUsageSectionTitle", - "aboutDataUsageData", - "aboutDataUsageCache", - "aboutDataUsageDatabase", - "aboutDataUsageMisc", "aboutDataUsageInternal", "aboutDataUsageExternal", - "statePageTitle", - "stateEmpty", - "searchStatesSectionTitle", - "settingsAskEverytime", "settingsCollectionBurstPatternsTile", "settingsCollectionBurstPatternsNone", "settingsViewerShowHistogram", - "settingsVideoPlaybackTile", - "settingsVideoPlaybackPageTitle", - "settingsVideoResumptionModeTile", - "settingsVideoResumptionModeDialogTitle", - "settingsVideoBackgroundMode", - "settingsVideoBackgroundModeDialogTitle", - "statsTopStatesSectionTitle", - "tagEditorDiscardDialogMessage", - "tagPlaceholderState" + "statsTopStatesSectionTitle" ], "nl": [ @@ -8692,13 +8627,6 @@ "tagPlaceholderState" ], - "uk": [ - "overlayHistogramNone", - "overlayHistogramRGB", - "overlayHistogramLuminance", - "settingsViewerShowHistogram" - ], - "zh": [ "saveCopyButtonLabel", "chipActionGoToPlacePage",