fix(mobile): move all colors to theme data

This commit is contained in:
Prateek Sunal 2024-06-11 21:27:42 +05:30
parent 3f736e82ae
commit 2b00418695
8 changed files with 55 additions and 22 deletions

View File

@ -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;

View File

@ -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<VideoCropPage> {
),
const SizedBox(height: 40),
VideoEditorNavigationOptions(
color: Theme.of(context).colorScheme.videoPlayerPrimaryColor,
secondaryText: "Done",
onSecondaryPressed: () {
// WAY 1: validate crop parameters set in the crop view

View File

@ -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,
),

View File

@ -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),
],

View File

@ -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(

View File

@ -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<VideoEditorPage> {
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<VideoEditorPage> {
),
const SizedBox(height: 40),
VideoEditorNavigationOptions(
color: Theme.of(context)
.colorScheme
.videoPlayerPrimaryColor,
secondaryText: "Save copy",
onSecondaryPressed: () {
exportVideo();
@ -232,13 +233,25 @@ class _VideoEditorPageState extends State<VideoEditorPage> {
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

View File

@ -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) {

View File

@ -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<VideoTrimPage> {
..._trimSlider(),
const SizedBox(height: 40),
VideoEditorNavigationOptions(
color: Theme.of(context).colorScheme.videoPlayerPrimaryColor,
secondaryText: "Done",
onPrimaryPressed: () {
// reset trim