diff --git a/mobile/apps/photos/analysis_options.yaml b/mobile/apps/photos/analysis_options.yaml index c444f8262e..952a9ae3bb 100644 --- a/mobile/apps/photos/analysis_options.yaml +++ b/mobile/apps/photos/analysis_options.yaml @@ -3,6 +3,11 @@ # use "flutter analyze ." or "dart analyze ." for running lint checks include: package:flutter_lints/flutter.yaml + +formatter: + trailing_commas: preserve + page_width: 80 + linter: rules: # Ref https://github.com/flutter/packages/blob/master/packages/flutter_lints/lib/flutter.yaml diff --git a/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart b/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart index 64fe799e46..471849220c 100644 --- a/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart +++ b/mobile/apps/photos/lib/ui/collections/collection_action_sheet.dart @@ -38,7 +38,7 @@ enum CollectionActionType { shareCollection, addToHiddenAlbum, moveToHiddenCollection, - autoAddPeople; + autoAddPeople, } extension CollectionActionTypeExtension on CollectionActionType { @@ -147,19 +147,20 @@ class _CollectionActionSheetState extends State { void initState() { super.initState(); _showOnlyHiddenCollections = widget.actionType.isHiddenAction; - _enableSelection = (widget.actionType == - CollectionActionType.autoAddPeople && + _enableSelection = + (widget.actionType == CollectionActionType.autoAddPeople && widget.selectedPeople != null) || ((widget.actionType == CollectionActionType.addFiles || widget.actionType == CollectionActionType.addToHiddenAlbum) && (widget.sharedFiles == null || widget.sharedFiles!.isEmpty)); - _createNewAlbumSubscription = - Bus.instance.on().listen((event) { - setState(() { - _recentlyCreatedCollections.insert(0, event.collection); - _selectedCollections.add(event.collection); - }); - }); + _createNewAlbumSubscription = Bus.instance.on().listen( + (event) { + setState(() { + _recentlyCreatedCollections.insert(0, event.collection); + _selectedCollections.add(event.collection); + }); + }, + ); } @override @@ -173,12 +174,14 @@ class _CollectionActionSheetState extends State { final filesCount = widget.sharedFiles != null ? widget.sharedFiles!.length : widget.selectedPeople != null - ? widget.selectedPeople!.length - : widget.selectedFiles?.files.length ?? 0; + ? widget.selectedPeople!.length + : widget.selectedFiles?.files.length ?? 0; final bottomInset = MediaQuery.viewInsetsOf(context).bottom; final isKeyboardUp = bottomInset > 100; - final double bottomPadding = - max(0, bottomInset - (_enableSelection ? okButtonSize : 0)); + final double bottomPadding = max( + 0, + bottomInset - (_enableSelection ? okButtonSize : 0), + ); return Padding( padding: EdgeInsets.only( bottom: isKeyboardUp ? bottomPadding : 0, @@ -275,12 +278,12 @@ class _CollectionActionSheetState extends State { isDisabled: _selectedCollections.isEmpty, onTap: () async { if (widget.selectedPeople != null) { - final ProgressDialog? dialog = createProgressDialog( + final ProgressDialog dialog = createProgressDialog( context, S.of(context).uploadingFilesToAlbum, isDismissible: true, ); - await dialog?.show(); + await dialog.show(); for (final collection in _selectedCollections) { try { await smartAlbumsService.addPeopleToSmartAlbum( @@ -296,11 +299,12 @@ class _CollectionActionSheetState extends State { } } unawaited(smartAlbumsService.syncSmartAlbums()); - await dialog?.hide(); + await dialog.hide(); return; } - final CollectionActions collectionActions = - CollectionActions(CollectionsService.instance); + final CollectionActions collectionActions = CollectionActions( + CollectionsService.instance, + ); final result = await collectionActions.addToMultipleCollections( context, _selectedCollections, @@ -342,12 +346,12 @@ class _CollectionActionSheetState extends State { widget.showOptionToCreateNewAlbum && _searchQuery.isEmpty; final searchResults = _searchQuery.isNotEmpty ? collections - .where( - (element) => element.displayName - .toLowerCase() - .contains(_searchQuery), - ) - .toList() + .where( + (element) => element.displayName + .toLowerCase() + .contains(_searchQuery), + ) + .toList() : collections; return Scrollbar( thumbVisibility: true, @@ -402,8 +406,8 @@ class _CollectionActionSheetState extends State { }); return recentlyCreated + hidden; } else { - final List collections = - CollectionsService.instance.getCollectionsForUI( + final List + collections = CollectionsService.instance.getCollectionsForUI( // in collections where user is a collaborator, only addTo and remove // action can to be performed includeCollab: widget.actionType == CollectionActionType.addFiles, diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart index 1ecc52a7b7..c21f3256b8 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart @@ -36,10 +36,8 @@ class CircularIconButton extends StatelessWidget { width: size, decoration: BoxDecoration( color: isSelected - ? Theme.of(context) - .colorScheme - .imageEditorPrimaryColor - .withOpacity(0.24) + ? Theme.of(context).colorScheme.imageEditorPrimaryColor + .withValues(alpha: 0.24) : Theme.of(context).colorScheme.editorBackgroundColor, shape: BoxShape.circle, border: Border.all( diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart index 726083d999..9123cbe268 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart @@ -80,14 +80,16 @@ class _ImageEditorPageState extends State { try { final fileName = path.basenameWithoutExtension(widget.originalFile.title!) + - "_edited_" + - DateTime.now().microsecondsSinceEpoch.toString() + - ".JPEG"; + "_edited_" + + DateTime.now().microsecondsSinceEpoch.toString() + + ".JPEG"; //Disabling notifications for assets changing to insert the file into //files db before triggering a sync. await PhotoManager.stopChangeNotify(); - final AssetEntity newAsset = - await (PhotoManager.editor.saveImage(result, filename: fileName)); + final AssetEntity newAsset = await (PhotoManager.editor.saveImage( + result, + filename: fileName, + )); final newFile = await ente.EnteFile.fromAsset( widget.originalFile.deviceFolder ?? '', newAsset, @@ -116,8 +118,9 @@ class _ImageEditorPageState extends State { // the index could be -1 if the files fetched doesn't contain the newly // edited files - int selectionIndex = - files.indexWhere((file) => file.generatedID == newFile.generatedID); + int selectionIndex = files.indexWhere( + (file) => file.generatedID == newFile.generatedID, + ); if (selectionIndex == -1) { files.add(newFile); selectionIndex = files.length - 1; @@ -178,7 +181,7 @@ class _ImageEditorPageState extends State { final textTheme = getEnteTextTheme(context); return PopScope( canPop: false, - onPopInvoked: (didPop) { + onPopInvokedWithResult: (didPop, _) { if (didPop) return; editorKey.currentState?.disablePopScope = true; _showExitConfirmationDialog(context); @@ -209,10 +212,12 @@ class _ImageEditorPageState extends State { uiOverlayStyle: SystemUiOverlayStyle( systemNavigationBarContrastEnforced: true, systemNavigationBarColor: Colors.transparent, - statusBarBrightness: - isLightMode ? Brightness.dark : Brightness.light, - statusBarIconBrightness: - isLightMode ? Brightness.dark : Brightness.light, + statusBarBrightness: isLightMode + ? Brightness.dark + : Brightness.light, + statusBarIconBrightness: isLightMode + ? Brightness.dark + : Brightness.light, ), appBarBackgroundColor: colorScheme.backgroundBase, background: colorScheme.backgroundBase, @@ -230,8 +235,9 @@ class _ImageEditorPageState extends State { ), cropRotateEditor: CropRotateEditorTheme( background: colorScheme.backgroundBase, - cropCornerColor: - Theme.of(context).colorScheme.imageEditorPrimaryColor, + cropCornerColor: Theme.of( + context, + ).colorScheme.imageEditorPrimaryColor, ), tuneEditor: TuneEditorTheme( background: colorScheme.backgroundBase, @@ -267,38 +273,39 @@ class _ImageEditorPageState extends State { ), customWidgets: ImageEditorCustomWidgets( filterEditor: CustomWidgetsFilterEditor( - slider: ( - editorState, - rebuildStream, - value, - onChanged, - onChangeEnd, - ) => - ReactiveCustomWidget( - builder: (context) { - return const SizedBox.shrink(); - }, - stream: rebuildStream, - ), - filterButton: ( - filter, - isSelected, - scaleFactor, - onSelectFilter, - editorImage, - filterKey, - ) { - return ImageEditorFilterBar( - filterModel: filter, - isSelected: isSelected, - onSelectFilter: () { - onSelectFilter.call(); - editorKey.currentState?.setState(() {}); + slider: + ( + editorState, + rebuildStream, + value, + onChanged, + onChangeEnd, + ) => ReactiveCustomWidget( + builder: (context) { + return const SizedBox.shrink(); + }, + stream: rebuildStream, + ), + filterButton: + ( + filter, + isSelected, + scaleFactor, + onSelectFilter, + editorImage, + filterKey, + ) { + return ImageEditorFilterBar( + filterModel: filter, + isSelected: isSelected, + onSelectFilter: () { + onSelectFilter.call(); + editorKey.currentState?.setState(() {}); + }, + editorImage: editorImage, + filterKey: filterKey, + ); }, - editorImage: editorImage, - filterKey: filterKey, - ); - }, appBar: (editor, rebuildStream) { return ReactiveCustomAppbar( builder: (context) { @@ -354,8 +361,10 @@ class _ImageEditorPageState extends State { child: StreamBuilder( stream: rebuildStream, builder: (context, snapshot) { - final isHovered = editorKey.currentState! - .layerInteractionManager.hoverRemoveBtn; + final isHovered = editorKey + .currentState! + .layerInteractionManager + .hoverRemoveBtn; return AnimatedContainer( key: key, @@ -365,7 +374,9 @@ class _ImageEditorPageState extends State { margin: const EdgeInsets.only(bottom: 24), decoration: BoxDecoration( color: isHovered - ? colorScheme.warning400.withOpacity(0.8) + ? colorScheme.warning400.withValues( + alpha: 0.8, + ) : Colors.white, shape: BoxShape.circle, ), @@ -376,8 +387,9 @@ class _ImageEditorPageState extends State { colorFilter: ColorFilter.mode( isHovered ? Colors.white - : colorScheme.warning400 - .withOpacity(0.8), + : colorScheme.warning400.withValues( + alpha: 0.8, + ), BlendMode.srcIn, ), ), @@ -526,13 +538,13 @@ class _ImageEditorPageState extends State { }, bottomBar: (cropRotateEditor, rebuildStream) => ReactiveCustomWidget( - stream: rebuildStream, - builder: (_) => ImageEditorCropRotateBar( - configs: cropRotateEditor.configs, - callbacks: cropRotateEditor.callbacks, - editor: cropRotateEditor, - ), - ), + stream: rebuildStream, + builder: (_) => ImageEditorCropRotateBar( + configs: cropRotateEditor.configs, + callbacks: cropRotateEditor.callbacks, + editor: cropRotateEditor, + ), + ), ), ), mainEditorConfigs: const MainEditorConfigs(enableZoom: true), diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart index 14a21e00f1..b99252fa0c 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart @@ -122,16 +122,16 @@ class _ImageEditorTextBarState extends State switchOutCurve: Curves.easeInOut, child: switch (selectedActionIndex) { 0 => ImageEditorColorPicker( - value: colorSliderValue, - onChanged: (value) { - setState(() { - colorSliderValue = value; - }); - final hue = value * 360; - final color = HSVColor.fromAHSV(1.0, hue, 1.0, 1.0).toColor(); - widget.editor.primaryColor = color; - }, - ), + value: colorSliderValue, + onChanged: (value) { + setState(() { + colorSliderValue = value; + }); + final hue = value * 360; + final color = HSVColor.fromAHSV(1.0, hue, 1.0, 1.0).toColor(); + widget.editor.primaryColor = color; + }, + ), 1 => _FontPickerWidget(editor: widget.editor), 2 => _BackgroundPickerWidget(editor: widget.editor), 3 => _AlignPickerWidget(editor: widget.editor), @@ -155,10 +155,9 @@ class _FontPickerWidget extends StatelessWidget { return Row( mainAxisAlignment: MainAxisAlignment.center, - children: editor.textEditorConfigs.customTextStyles! - .asMap() - .entries - .map((entry) { + children: editor.textEditorConfigs.customTextStyles!.asMap().entries.map(( + entry, + ) { final item = entry.value; final selected = editor.selectedTextStyle; final bool isSelected = selected.hashCode == item.hashCode; @@ -208,8 +207,9 @@ class _BackgroundPickerWidget extends StatelessWidget { final backgroundStyles = { LayerBackgroundMode.background: { 'text': 'Aa', - 'selectedBackgroundColor': - isLightMode ? colorScheme.fillFaint : Colors.white, + 'selectedBackgroundColor': isLightMode + ? colorScheme.fillFaint + : Colors.white, 'backgroundColor': Theme.of(context).colorScheme.editorBackgroundColor, 'border': null, 'textColor': Colors.white, @@ -218,8 +218,9 @@ class _BackgroundPickerWidget extends StatelessWidget { }, LayerBackgroundMode.backgroundAndColor: { 'text': 'Aa', - 'selectedBackgroundColor': - isLightMode ? colorScheme.fillFaint : Colors.white, + 'selectedBackgroundColor': isLightMode + ? colorScheme.fillFaint + : Colors.white, 'backgroundColor': Theme.of(context).colorScheme.editorBackgroundColor, 'border': null, 'textColor': Colors.black, @@ -228,26 +229,29 @@ class _BackgroundPickerWidget extends StatelessWidget { }, LayerBackgroundMode.backgroundAndColorWithOpacity: { 'text': 'Aa', - 'selectedBackgroundColor': - isLightMode ? colorScheme.fillFaint : Colors.white, + 'selectedBackgroundColor': isLightMode + ? colorScheme.fillFaint + : Colors.white, 'backgroundColor': Theme.of(context).colorScheme.editorBackgroundColor, 'border': null, 'textColor': Colors.black, - 'selectedInnerBackgroundColor': Colors.black.withOpacity(0.11), + 'selectedInnerBackgroundColor': Colors.black.withValues(alpha: 0.11), 'innerBackgroundColor': isLightMode - ? Colors.black.withOpacity(0.11) - : Colors.white.withOpacity(0.11), + ? Colors.black.withValues(alpha: 0.11) + : Colors.white.withValues(alpha: 0.11), }, LayerBackgroundMode.onlyColor: { 'text': 'Aa', - 'selectedBackgroundColor': - isLightMode ? colorScheme.fillFaint : Colors.black, + 'selectedBackgroundColor': isLightMode + ? colorScheme.fillFaint + : Colors.black, 'backgroundColor': Theme.of(context).colorScheme.editorBackgroundColor, - 'border': - isLightMode ? null : Border.all(color: Colors.white, width: 2), + 'border': isLightMode + ? null + : Border.all(color: Colors.white, width: 2), 'textColor': Colors.black, 'selectedInnerBackgroundColor': Colors.white, - 'innerBackgroundColor': Colors.white.withOpacity(0.6), + 'innerBackgroundColor': Colors.white.withValues(alpha: 0.6), }, }; @@ -327,11 +331,11 @@ class _AlignPickerWidget extends StatelessWidget { (TextAlign.left, "assets/image-editor/image-editor-text-align-left.svg"), ( TextAlign.center, - "assets/image-editor/image-editor-text-align-center.svg" + "assets/image-editor/image-editor-text-align-center.svg", ), ( TextAlign.right, - "assets/image-editor/image-editor-text-align-right.svg" + "assets/image-editor/image-editor-text-align-right.svg", ), ]; diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart index 7dcf73d4ed..784fe862bc 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart @@ -87,18 +87,20 @@ class _ImageEditorTuneBarState extends State mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, children: List.generate( - tuneEditor.tuneAdjustmentMatrix.length, (index) { - final item = tuneEditor.tuneAdjustmentList[index]; - return TuneItem( - icon: item.icon, - label: item.label, - isSelected: tuneEditor.selectedIndex == index, - value: tuneEditor.tuneAdjustmentMatrix[index].value, - max: item.max, - min: item.min, - onTap: () => _handleTuneItemTap(index), - ); - }), + tuneEditor.tuneAdjustmentMatrix.length, + (index) { + final item = tuneEditor.tuneAdjustmentList[index]; + return TuneItem( + icon: item.icon, + label: item.label, + isSelected: tuneEditor.selectedIndex == index, + value: tuneEditor.tuneAdjustmentMatrix[index].value, + max: item.max, + min: item.min, + onTap: () => _handleTuneItemTap(index), + ); + }, + ), ), ), ), @@ -163,8 +165,9 @@ class TuneItem extends StatelessWidget { size: 60, icon: icon, isSelected: isSelected, - progressColor: - Theme.of(context).colorScheme.imageEditorPrimaryColor, + progressColor: Theme.of( + context, + ).colorScheme.imageEditorPrimaryColor, svgPath: "assets/image-editor/image-editor-${label.toLowerCase()}.svg", ), @@ -223,15 +226,16 @@ class _CircularProgressWithValueState extends State animationBehavior: AnimationBehavior.preserve, ); - _progressAnimation = Tween( - begin: 0.0, - end: widget.value, - ).animate( - CurvedAnimation( - parent: _animationController, - curve: Curves.easeInOut, - ), - ); + _progressAnimation = + Tween( + begin: 0.0, + end: widget.value, + ).animate( + CurvedAnimation( + parent: _animationController, + curve: Curves.easeInOut, + ), + ); _animationController.forward(); } @@ -245,15 +249,16 @@ class _CircularProgressWithValueState extends State } if (oldWidget.value != widget.value) { _previousValue = oldWidget.value; - _progressAnimation = Tween( - begin: _previousValue, - end: widget.value, - ).animate( - CurvedAnimation( - parent: _animationController, - curve: Curves.easeInOut, - ), - ); + _progressAnimation = + Tween( + begin: _previousValue, + end: widget.value, + ).animate( + CurvedAnimation( + parent: _animationController, + curve: Curves.easeInOut, + ), + ); _animationController.forward(from: 0.0); } } @@ -300,8 +305,11 @@ class _CircularProgressWithValueState extends State Widget build(BuildContext context) { final colorTheme = getEnteColorScheme(context); final textTheme = getEnteTextTheme(context); - final displayValue = - _normalizeValueForDisplay(widget.value, widget.min, widget.max); + final displayValue = _normalizeValueForDisplay( + widget.value, + widget.min, + widget.max, + ); final displayText = displayValue.toString(); final prefix = displayValue > 0 ? "+" : ""; final progressColor = widget.progressColor; @@ -320,11 +328,11 @@ class _CircularProgressWithValueState extends State decoration: BoxDecoration( shape: BoxShape.circle, color: showValue || widget.isSelected - ? progressColor.withOpacity(0.2) + ? progressColor.withValues(alpha: 0.2) : Theme.of(context).colorScheme.editorBackgroundColor, border: Border.all( color: widget.isSelected - ? progressColor.withOpacity(0.4) + ? progressColor.withValues(alpha: 0.4) : Theme.of(context).colorScheme.editorBackgroundColor, width: 2, ), @@ -333,11 +341,15 @@ class _CircularProgressWithValueState extends State AnimatedBuilder( animation: _progressAnimation, builder: (context, child) { - final animatedValue = - displayValue == 0 ? 0.0 : _progressAnimation.value; + final animatedValue = displayValue == 0 + ? 0.0 + : _progressAnimation.value; - final isClockwise = - _isClockwise(animatedValue, widget.min, widget.max); + final isClockwise = _isClockwise( + animatedValue, + widget.min, + widget.max, + ); final progressValue = _normalizeValueForProgress( animatedValue, widget.min, @@ -365,21 +377,21 @@ class _CircularProgressWithValueState extends State style: textTheme.smallBold, ) : widget.svgPath != null - ? SvgPicture.asset( - widget.svgPath!, - width: 22, - height: 22, - fit: BoxFit.scaleDown, - colorFilter: ColorFilter.mode( - colorTheme.tabIcon, - BlendMode.srcIn, - ), - ) - : Icon( - widget.icon, - color: colorTheme.tabIcon, - size: 20, - ), + ? SvgPicture.asset( + widget.svgPath!, + width: 22, + height: 22, + fit: BoxFit.scaleDown, + colorFilter: ColorFilter.mode( + colorTheme.tabIcon, + BlendMode.srcIn, + ), + ) + : Icon( + widget.icon, + color: colorTheme.tabIcon, + size: 20, + ), ), ], ), @@ -426,10 +438,12 @@ class _TuneAdjustWidget extends StatelessWidget { data: SliderTheme.of(context).copyWith( thumbShape: const _ColorPickerThumbShape(), overlayShape: const RoundSliderOverlayShape(overlayRadius: 0), - activeTrackColor: - Theme.of(context).colorScheme.imageEditorPrimaryColor, - inactiveTrackColor: - Theme.of(context).colorScheme.editorBackgroundColor, + activeTrackColor: Theme.of( + context, + ).colorScheme.imageEditorPrimaryColor, + inactiveTrackColor: Theme.of( + context, + ).colorScheme.editorBackgroundColor, trackShape: const _CenterBasedTrackShape(), trackHeight: 24, ), diff --git a/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart index ebe92217cb..966187d941 100644 --- a/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart +++ b/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart @@ -66,7 +66,8 @@ class _SmartAlbumsStatusWidgetState extends State firstCurve: Curves.easeInOutExpo, secondCurve: Curves.easeInOutExpo, sizeCurve: Curves.easeInOutExpo, - crossFadeState: !(_syncingCollection == null || + crossFadeState: + !(_syncingCollection == null || _syncingCollection!.$1 != widget.collection?.id) ? CrossFadeState.showSecond : CrossFadeState.showFirst, @@ -76,11 +77,13 @@ class _SmartAlbumsStatusWidgetState extends State crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12) - .copyWith(left: 14), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ).copyWith(left: 14), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), - color: Colors.black.withOpacity(0.65), + color: Colors.black.withValues(alpha: 0.65), ), child: Row( mainAxisSize: MainAxisSize.min, diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart index 3c25a9ed4b..74d5b1d7af 100644 --- a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart +++ b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart @@ -84,8 +84,10 @@ class _CustomScrollBarState extends State { } if (_showScrollbarDivisions) { - getIntrinsicSizeOfWidget(const ScrollBarDivider(title: "Temp"), context) - .then((size) { + getIntrinsicSizeOfWidget( + const ScrollBarDivider(title: "Temp"), + context, + ).then((size) { if (mounted) { setState(() { heightOfScrollbarDivider = size.height; @@ -114,7 +116,8 @@ class _CustomScrollBarState extends State { for (final scrollbarDivision in widget.galleryGroups.scrollbarDivisions) { final scrollOffsetOfGroup = widget - .galleryGroups.groupIdToScrollOffsetMap[scrollbarDivision.groupID]!; + .galleryGroups + .groupIdToScrollOffsetMap[scrollbarDivision.groupID]!; final groupScrollOffsetToUse = scrollOffsetOfGroup - heightOfScrollTrack!; if (groupScrollOffsetToUse < 0) { @@ -142,19 +145,20 @@ class _CustomScrollBarState extends State { final value = (_kScrollbarMinLength - heightOfScrollbarDivider!) / 2; if (fractionOfGroupScrollOffsetWrtMaxExtent < 0.5) { - positionCorrection = value * fractionOfGroupScrollOffsetWrtMaxExtent - + positionCorrection = + value * fractionOfGroupScrollOffsetWrtMaxExtent - (heightOfScrollbarDivider! * fractionOfGroupScrollOffsetWrtMaxExtent); } else { positionCorrection = -value * fractionOfGroupScrollOffsetWrtMaxExtent - - (heightOfScrollbarDivider! * - fractionOfGroupScrollOffsetWrtMaxExtent); + (heightOfScrollbarDivider! * + fractionOfGroupScrollOffsetWrtMaxExtent); } final adaptedPosition = heightOfScrollTrack! * fractionOfGroupScrollOffsetWrtMaxExtent + - positionCorrection; + positionCorrection; result.add( (position: adaptedPosition, title: scrollbarDivision.title), @@ -279,7 +283,7 @@ class ScrollBarDivider extends StatelessWidget { // is affected. boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), blurRadius: 3, offset: const Offset(0, 2), ), diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart index c0a2b27608..d2479bf1da 100644 --- a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart +++ b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart @@ -53,11 +53,11 @@ const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600); /// {@end-tool} /// /// A scrollbar track can be added using [trackVisibility]. This can also be -/// drawn when triggered by a hover event, or based on any [MaterialState] by +/// drawn when triggered by a hover event, or based on any [WidgetState] by /// using [ScrollbarThemeData.trackVisibility]. /// /// The [thickness] of the track and scrollbar thumb can be changed dynamically -/// in response to [MaterialState]s using [ScrollbarThemeData.thickness]. +/// in response to [WidgetState]s using [ScrollbarThemeData.thickness]. /// /// See also: /// @@ -207,12 +207,12 @@ class _MaterialScrollbar extends RawScrollbar { super.interactive, super.scrollbarOrientation, }) : super( - fadeDuration: _kScrollbarFadeDuration, - timeToFade: _kScrollbarTimeToFade, - pressDuration: Duration.zero, - notificationPredicate: - notificationPredicate ?? defaultScrollNotificationPredicate, - ); + fadeDuration: _kScrollbarFadeDuration, + timeToFade: _kScrollbarTimeToFade, + pressDuration: Duration.zero, + notificationPredicate: + notificationPredicate ?? defaultScrollNotificationPredicate, + ); @override _MaterialScrollbarState createState() => _MaterialScrollbarState(); @@ -247,9 +247,9 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { }); Set get _states => { - if (_dragIsActive) WidgetState.dragged, - if (_hoverIsActive) WidgetState.hovered, - }; + if (_dragIsActive) WidgetState.dragged, + if (_hoverIsActive) WidgetState.hovered, + }; WidgetStateProperty get _thumbColor { if (widget.showThumb == false) { @@ -262,17 +262,17 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { late Color idleColor; switch (brightness) { case Brightness.light: - dragColor = onSurface.withOpacity(0.6); - hoverColor = onSurface.withOpacity(0.5); + dragColor = onSurface.withValues(alpha: 0.6); + hoverColor = onSurface.withValues(alpha: 0.5); idleColor = _useAndroidScrollbar - ? Theme.of(context).highlightColor.withOpacity(1.0) - : onSurface.withOpacity(0.1); + ? Theme.of(context).highlightColor.withValues(alpha: 1.0) + : onSurface.withValues(alpha: 0.1); case Brightness.dark: - dragColor = onSurface.withOpacity(0.75); - hoverColor = onSurface.withOpacity(0.65); + dragColor = onSurface.withValues(alpha: 0.75); + hoverColor = onSurface.withValues(alpha: 0.65); idleColor = _useAndroidScrollbar - ? Theme.of(context).highlightColor.withOpacity(1.0) - : onSurface.withOpacity(0.3); + ? Theme.of(context).highlightColor.withValues(alpha: 1.0) + : onSurface.withValues(alpha: 0.3); } return WidgetStateProperty.resolveWith((Set states) { @@ -304,8 +304,8 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { if (showScrollbar && _trackVisibility.resolve(states)) { return _scrollbarTheme.trackColor?.resolve(states) ?? switch (brightness) { - Brightness.light => onSurface.withOpacity(0.03), - Brightness.dark => onSurface.withOpacity(0.05), + Brightness.light => onSurface.withValues(alpha: 0.03), + Brightness.dark => onSurface.withValues(alpha: 0.05), }; } return const Color(0x00000000); @@ -322,8 +322,8 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { if (showScrollbar && _trackVisibility.resolve(states)) { return _scrollbarTheme.trackBorderColor?.resolve(states) ?? switch (brightness) { - Brightness.light => onSurface.withOpacity(0.1), - Brightness.dark => onSurface.withOpacity(0.25), + Brightness.light => onSurface.withValues(alpha: 0.1), + Brightness.dark => onSurface.withValues(alpha: 0.25), }; } return const Color(0x00000000); @@ -383,10 +383,12 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { ..trackBorderColor = _trackBorderColor.resolve(_states) ..textDirection = Directionality.of(context) ..thickness = _thickness.resolve(_states) - ..radius = widget.radius ?? + ..radius = + widget.radius ?? _scrollbarTheme.radius ?? (_useAndroidScrollbar ? null : _kScrollbarRadius) - ..crossAxisMargin = _scrollbarTheme.crossAxisMargin ?? + ..crossAxisMargin = + _scrollbarTheme.crossAxisMargin ?? (_useAndroidScrollbar ? 0.0 : _kScrollbarMargin) ..mainAxisMargin = _scrollbarTheme.mainAxisMargin ?? 0.0 ..minLength = widget.minScrollbarLength diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock index d9ef339a3a..f0e5f4e218 100644 --- a/mobile/apps/photos/pubspec.lock +++ b/mobile/apps/photos/pubspec.lock @@ -3028,5 +3028,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.7.2 <4.0.0" + dart: ">=3.8.0 <4.0.0" flutter: ">=3.29.0" diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml index 63db0d4076..70c9f1e428 100644 --- a/mobile/apps/photos/pubspec.yaml +++ b/mobile/apps/photos/pubspec.yaml @@ -16,7 +16,7 @@ version: 1.2.1+1205 publish_to: none environment: - sdk: ">=3.3.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" dependencies: adaptive_theme: ^3.1.0