From 2b0041869573b6d4dc80196a8d0180ace88d94cf Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 11 Jun 2024 21:27:42 +0530 Subject: [PATCH] fix(mobile): move all colors to theme data --- mobile/lib/ente_theme_data.dart | 12 ++++++- .../lib/ui/tools/editor/video_crop_page.dart | 2 ++ .../video_editor_bottom_action.dart | 9 ++--- .../video_editor_navigation_options.dart | 10 +++++- .../video_editor_player_control.dart | 5 ++- .../ui/tools/editor/video_editor_page.dart | 35 +++++++++++++------ .../ui/tools/editor/video_rotate_page.dart | 2 ++ .../lib/ui/tools/editor/video_trim_page.dart | 2 ++ 8 files changed, 55 insertions(+), 22 deletions(-) diff --git a/mobile/lib/ente_theme_data.dart b/mobile/lib/ente_theme_data.dart index 0715ba8d19..8e8ed61523 100644 --- a/mobile/lib/ente_theme_data.dart +++ b/mobile/lib/ente_theme_data.dart @@ -220,7 +220,17 @@ TextTheme _buildTextTheme(Color textColor) { } extension CustomColorScheme on ColorScheme { - Color get videoPlayerPrimaryColor => const Color.fromRGBO(1, 222, 77, 1); + Color get videoPlayerPrimaryColor => brightness == Brightness.light + ? const Color.fromRGBO(0, 179, 60, 1) + : const Color.fromRGBO(1, 222, 77, 1); + + Color get videoPlayerBackgroundColor => brightness == Brightness.light + ? const Color(0xFFF5F5F5) + : const Color(0xFF252525); + + Color get videoPlayerBorderColor => brightness == Brightness.light + ? const Color(0xFF424242) + : const Color(0xFFFFFFFF); Color get defaultBackgroundColor => brightness == Brightness.light ? backgroundBaseLight : backgroundBaseDark; diff --git a/mobile/lib/ui/tools/editor/video_crop_page.dart b/mobile/lib/ui/tools/editor/video_crop_page.dart index f10bab3e82..61becf3917 100644 --- a/mobile/lib/ui/tools/editor/video_crop_page.dart +++ b/mobile/lib/ui/tools/editor/video_crop_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import "package:photos/ente_theme_data.dart"; import "package:photos/ui/tools/editor/video_editor/crop_value.dart"; import "package:photos/ui/tools/editor/video_editor/video_editor_bottom_action.dart"; import "package:photos/ui/tools/editor/video_editor/video_editor_main_actions.dart"; @@ -85,6 +86,7 @@ class _VideoCropPageState extends State { ), const SizedBox(height: 40), VideoEditorNavigationOptions( + color: Theme.of(context).colorScheme.videoPlayerPrimaryColor, secondaryText: "Done", onSecondaryPressed: () { // WAY 1: validate crop parameters set in the crop view diff --git a/mobile/lib/ui/tools/editor/video_editor/video_editor_bottom_action.dart b/mobile/lib/ui/tools/editor/video_editor/video_editor_bottom_action.dart index cb32edec43..ed21e96dbf 100644 --- a/mobile/lib/ui/tools/editor/video_editor/video_editor_bottom_action.dart +++ b/mobile/lib/ui/tools/editor/video_editor/video_editor_bottom_action.dart @@ -1,5 +1,6 @@ import "package:flutter/material.dart"; import "package:flutter_svg/flutter_svg.dart"; +import "package:photos/ente_theme_data.dart"; class VideoEditorBottomAction extends StatelessWidget { const VideoEditorBottomAction({ @@ -30,15 +31,11 @@ class VideoEditorBottomAction extends StatelessWidget { height: 48, width: 48, decoration: BoxDecoration( - color: Theme.of(context).brightness == Brightness.light - ? const Color(0xFFF5F5F5) - : const Color(0xFF252525), + color: Theme.of(context).colorScheme.videoPlayerBackgroundColor, shape: BoxShape.circle, border: Border.all( color: isSelected - ? Theme.of(context).brightness == Brightness.light - ? const Color(0xFF424242) - : const Color(0xFFFFFFFF) + ? Theme.of(context).colorScheme.videoPlayerBorderColor : Colors.transparent, width: 1, ), diff --git a/mobile/lib/ui/tools/editor/video_editor/video_editor_navigation_options.dart b/mobile/lib/ui/tools/editor/video_editor/video_editor_navigation_options.dart index 6a1d98cde7..1470ddc7ad 100644 --- a/mobile/lib/ui/tools/editor/video_editor/video_editor_navigation_options.dart +++ b/mobile/lib/ui/tools/editor/video_editor/video_editor_navigation_options.dart @@ -5,6 +5,7 @@ class VideoEditorNavigationOptions extends StatelessWidget { super.key, this.primaryText, this.onPrimaryPressed, + this.color, required this.secondaryText, required this.onSecondaryPressed, }); @@ -13,6 +14,7 @@ class VideoEditorNavigationOptions extends StatelessWidget { final VoidCallback? onPrimaryPressed; final String secondaryText; final VoidCallback? onSecondaryPressed; + final Color? color; @override Widget build(BuildContext context) { @@ -30,7 +32,13 @@ class VideoEditorNavigationOptions extends StatelessWidget { const Spacer(), TextButton( onPressed: onSecondaryPressed, - child: Text(secondaryText), + style: TextButton.styleFrom( + foregroundColor: color, + ), + child: Text( + secondaryText, + style: TextStyle(color: color), + ), ), const SizedBox(width: 28), ], diff --git a/mobile/lib/ui/tools/editor/video_editor/video_editor_player_control.dart b/mobile/lib/ui/tools/editor/video_editor/video_editor_player_control.dart index e6b25d69b8..719b62dd60 100644 --- a/mobile/lib/ui/tools/editor/video_editor/video_editor_player_control.dart +++ b/mobile/lib/ui/tools/editor/video_editor/video_editor_player_control.dart @@ -1,4 +1,5 @@ import "package:flutter/material.dart"; +import "package:photos/ente_theme_data.dart"; import "package:video_editor/video_editor.dart"; class VideoEditorPlayerControl extends StatelessWidget { @@ -42,9 +43,7 @@ class VideoEditorPlayerControl extends StatelessWidget { vertical: 4, ), decoration: BoxDecoration( - color: Theme.of(context).brightness == Brightness.light - ? const Color(0xFFF5F5F5) - : const Color(0xFF252525), + color: Theme.of(context).colorScheme.videoPlayerBackgroundColor, borderRadius: BorderRadius.circular(56), ), child: Row( diff --git a/mobile/lib/ui/tools/editor/video_editor_page.dart b/mobile/lib/ui/tools/editor/video_editor_page.dart index b539a73c3c..0aaf1bc35c 100644 --- a/mobile/lib/ui/tools/editor/video_editor_page.dart +++ b/mobile/lib/ui/tools/editor/video_editor_page.dart @@ -12,6 +12,7 @@ import "package:photos/ente_theme_data.dart"; import "package:photos/events/local_photos_updated_event.dart"; import "package:photos/generated/l10n.dart"; import "package:photos/models/file/file.dart"; +import "package:photos/models/location/location.dart"; import "package:photos/services/sync_service.dart"; import "package:photos/ui/tools/editor/export_video_service.dart"; import 'package:photos/ui/tools/editor/video_crop_page.dart'; @@ -65,15 +66,12 @@ class _VideoEditorPageState extends State { trimStyle: TrimSliderStyle( onTrimmedColor: const ColorScheme.dark().videoPlayerPrimaryColor, onTrimmingColor: const ColorScheme.dark().videoPlayerPrimaryColor, - background: Theme.of(context).brightness == Brightness.light - ? const Color(0xFFF5F5F5) - : const Color(0xFF252525), - positionLineColor: Theme.of(context).brightness == Brightness.light - ? const Color(0xFF424242) - : const Color(0xFFFFFFFF), - lineColor: (Theme.of(context).brightness == Brightness.light - ? const Color(0xFF424242) - : const Color(0xFFFFFFFF)) + background: Theme.of(context).colorScheme.videoPlayerBackgroundColor, + positionLineColor: + Theme.of(context).colorScheme.videoPlayerBorderColor, + lineColor: Theme.of(context) + .colorScheme + .videoPlayerBorderColor .withOpacity(0.6), ), ); @@ -173,6 +171,9 @@ class _VideoEditorPageState extends State { ), const SizedBox(height: 40), VideoEditorNavigationOptions( + color: Theme.of(context) + .colorScheme + .videoPlayerPrimaryColor, secondaryText: "Save copy", onSecondaryPressed: () { exportVideo(); @@ -232,13 +233,25 @@ class _VideoEditorPageState extends State { final AssetEntity? newAsset = await (PhotoManager.editor.saveVideo(result, title: fileName)); result.deleteSync(); - (await newAsset?.file) - ?.setLastModifiedSync(widget.ioFile.lastModifiedSync()); final newFile = await EnteFile.fromAsset( widget.file.deviceFolder ?? '', newAsset!, ); + newFile.creationTime = widget.file.creationTime; + newFile.collectionID = widget.file.collectionID; + newFile.location = widget.file.location; + if (!newFile.hasLocation && widget.file.localID != null) { + final assetEntity = await widget.file.getAsset; + if (assetEntity != null) { + final latLong = await assetEntity.latlngAsync(); + newFile.location = Location( + latitude: latLong.latitude, + longitude: latLong.longitude, + ); + } + } + newFile.generatedID = await FilesDB.instance.insertAndGetId(widget.file); Bus.instance diff --git a/mobile/lib/ui/tools/editor/video_rotate_page.dart b/mobile/lib/ui/tools/editor/video_rotate_page.dart index 3c53ca32f3..efd2d896a7 100644 --- a/mobile/lib/ui/tools/editor/video_rotate_page.dart +++ b/mobile/lib/ui/tools/editor/video_rotate_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import "package:photos/ente_theme_data.dart"; import "package:photos/ui/tools/editor/video_editor/video_editor_bottom_action.dart"; import "package:photos/ui/tools/editor/video_editor/video_editor_main_actions.dart"; import "package:photos/ui/tools/editor/video_editor/video_editor_navigation_options.dart"; @@ -51,6 +52,7 @@ class VideoRotatePage extends StatelessWidget { ), const SizedBox(height: 40), VideoEditorNavigationOptions( + color: Theme.of(context).colorScheme.videoPlayerPrimaryColor, secondaryText: "Done", onPrimaryPressed: () { while (controller.rotation != rotation) { diff --git a/mobile/lib/ui/tools/editor/video_trim_page.dart b/mobile/lib/ui/tools/editor/video_trim_page.dart index 0c044dcb23..d1d875b3f1 100644 --- a/mobile/lib/ui/tools/editor/video_trim_page.dart +++ b/mobile/lib/ui/tools/editor/video_trim_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import "package:photos/ente_theme_data.dart"; import "package:photos/ui/tools/editor/video_editor/video_editor_navigation_options.dart"; import "package:photos/ui/tools/editor/video_editor/video_editor_player_control.dart"; import 'package:video_editor/video_editor.dart'; @@ -42,6 +43,7 @@ class _VideoTrimPageState extends State { ..._trimSlider(), const SizedBox(height: 40), VideoEditorNavigationOptions( + color: Theme.of(context).colorScheme.videoPlayerPrimaryColor, secondaryText: "Done", onPrimaryPressed: () { // reset trim