Browse Source

Merge pull request #271 from ente-io/manage-link-screen

Manage link screen and datetime picker for light theme
Neeraj Gupta 3 years ago
parent
commit
00abf211e3

+ 0 - 6
lib/app.dart

@@ -57,9 +57,6 @@ final lightThemeData = ThemeData(
           fontSize: 14,
           fontSize: 14,
           fontWeight: FontWeight.w500),
           fontWeight: FontWeight.w500),
       shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))),
       shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))),
-  // textSelectionTheme: TextSelectionThemeData().copyWith(
-  //   cursorColor: Colors.black.withOpacity(0.5),
-  // ),
   inputDecorationTheme: InputDecorationTheme().copyWith(
   inputDecorationTheme: InputDecorationTheme().copyWith(
     focusedBorder: UnderlineInputBorder(
     focusedBorder: UnderlineInputBorder(
       borderSide: BorderSide(
       borderSide: BorderSide(
@@ -126,9 +123,6 @@ final darkThemeData = ThemeData(
           fontSize: 14,
           fontSize: 14,
           fontWeight: FontWeight.w500),
           fontWeight: FontWeight.w500),
       shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))),
       shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))),
-  // textSelectionTheme: TextSelectionThemeData().copyWith(
-  //   cursorColor: Colors.white.withOpacity(0.5),
-  // ),
   inputDecorationTheme: InputDecorationTheme().copyWith(
   inputDecorationTheme: InputDecorationTheme().copyWith(
     focusedBorder: UnderlineInputBorder(
     focusedBorder: UnderlineInputBorder(
       borderSide: BorderSide(
       borderSide: BorderSide(

+ 18 - 1
lib/ente_theme_data.dart

@@ -1,6 +1,7 @@
 import 'dart:ui';
 import 'dart:ui';
 
 
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
+import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
 
 
 extension CustomColorScheme on ColorScheme {
 extension CustomColorScheme on ColorScheme {
   Color get defaultTextColor =>
   Color get defaultTextColor =>
@@ -12,6 +13,9 @@ extension CustomColorScheme on ColorScheme {
   Color get inverseIconColor =>
   Color get inverseIconColor =>
       brightness == Brightness.light ? Colors.white : Colors.black;
       brightness == Brightness.light ? Colors.white : Colors.black;
 
 
+  Color get inverseBackgroundColor =>
+      brightness == Brightness.light ? Colors.black : Colors.white;
+
   Color get boxSelectColor => brightness == Brightness.light
   Color get boxSelectColor => brightness == Brightness.light
       ? Color.fromRGBO(67, 186, 108, 1)
       ? Color.fromRGBO(67, 186, 108, 1)
       : Color.fromRGBO(16, 32, 32, 1);
       : Color.fromRGBO(16, 32, 32, 1);
@@ -38,7 +42,6 @@ extension CustomColorScheme on ColorScheme {
 
 
   Color get frostyBlurBackdropFilterColor =>
   Color get frostyBlurBackdropFilterColor =>
       Colors.white; //same for both themes
       Colors.white; //same for both themes
-  // brightness == Brightness.light ? Colors.black : Colors.white;
 
 
   Color get cancelSelectedButtonColor => brightness == Brightness.light
   Color get cancelSelectedButtonColor => brightness == Brightness.light
       ? Color.fromRGBO(0, 0, 0, 0.35)
       ? Color.fromRGBO(0, 0, 0, 0.35)
@@ -49,6 +52,20 @@ extension CustomColorScheme on ColorScheme {
       : Color.fromRGBO(10, 15, 15, 1.0);
       : Color.fromRGBO(10, 15, 15, 1.0);
 
 
   Color get greenText => Color.fromRGBO(40, 190, 92, 1);
   Color get greenText => Color.fromRGBO(40, 190, 92, 1);
+
+  Color get cupertinoPickerTopColor => brightness == Brightness.light
+      ? Color.fromARGB(255, 238, 238, 238)
+      : Colors.white.withOpacity(0.1);
+
+  DatePickerTheme get dateTimePickertheme => brightness == Brightness.light
+      ? DatePickerTheme(
+          backgroundColor: Colors.white,
+          itemStyle: TextStyle(color: Colors.black),
+          cancelStyle: TextStyle(color: Colors.black))
+      : DatePickerTheme(
+          backgroundColor: Colors.black,
+          itemStyle: TextStyle(color: Colors.white),
+          cancelStyle: TextStyle(color: Colors.white));
 }
 }
 
 
 OutlinedButtonThemeData buildOutlinedButtonThemeData(
 OutlinedButtonThemeData buildOutlinedButtonThemeData(

+ 0 - 12
lib/ui/common/widget_theme.dart

@@ -1,12 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
-
-const kDatePickerTheme = DatePickerTheme(
-  backgroundColor: Colors.black,
-  itemStyle: TextStyle(
-    color: Colors.white,
-  ),
-  cancelStyle: TextStyle(
-    color: Colors.white,
-  ),
-);

+ 3 - 12
lib/ui/fading_app_bar.dart

@@ -9,6 +9,7 @@ import 'package:logging/logging.dart';
 import 'package:photo_manager/photo_manager.dart';
 import 'package:photo_manager/photo_manager.dart';
 import 'package:photos/core/event_bus.dart';
 import 'package:photos/core/event_bus.dart';
 import 'package:photos/db/files_db.dart';
 import 'package:photos/db/files_db.dart';
+import 'package:photos/ente_theme_data.dart';
 import 'package:photos/events/local_photos_updated_event.dart';
 import 'package:photos/events/local_photos_updated_event.dart';
 import 'package:photos/models/file.dart';
 import 'package:photos/models/file.dart';
 import 'package:photos/models/file_type.dart';
 import 'package:photos/models/file_type.dart';
@@ -253,7 +254,7 @@ class FadingAppBarState extends State<FadingAppBar> {
       maxTime: DateTime.now(),
       maxTime: DateTime.now(),
       currentTime: DateTime.fromMicrosecondsSinceEpoch(file.creationTime),
       currentTime: DateTime.fromMicrosecondsSinceEpoch(file.creationTime),
       locale: LocaleType.en,
       locale: LocaleType.en,
-      theme: kDatePickerTheme,
+      theme: Theme.of(context).colorScheme.dateTimePickertheme,
     );
     );
     if (dateResult == null) {
     if (dateResult == null) {
       return;
       return;
@@ -263,7 +264,7 @@ class FadingAppBarState extends State<FadingAppBar> {
       showTitleActions: true,
       showTitleActions: true,
       currentTime: dateResult,
       currentTime: dateResult,
       locale: LocaleType.en,
       locale: LocaleType.en,
-      theme: kDatePickerTheme,
+      theme: Theme.of(context).colorScheme.dateTimePickertheme,
     );
     );
     if (dateWithTimeResult != null) {
     if (dateWithTimeResult != null) {
       if (await editTime(context, List.of([widget.file]),
       if (await editTime(context, List.of([widget.file]),
@@ -369,13 +370,3 @@ class FadingAppBarState extends State<FadingAppBar> {
     }
     }
   }
   }
 }
 }
-
-const kDatePickerTheme = DatePickerTheme(
-  backgroundColor: Colors.black,
-  itemStyle: TextStyle(
-    color: Colors.white,
-  ),
-  cancelStyle: TextStyle(
-    color: Colors.white,
-  ),
-);

+ 43 - 45
lib/ui/manage_links_widget.dart

@@ -4,10 +4,10 @@ import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
 import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
 import 'package:flutter_sodium/flutter_sodium.dart';
 import 'package:flutter_sodium/flutter_sodium.dart';
+import 'package:photos/ente_theme_data.dart';
 import 'package:photos/models/collection.dart';
 import 'package:photos/models/collection.dart';
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/common/dialogs.dart';
-import 'package:photos/ui/common/widget_theme.dart';
 import 'package:photos/utils/crypto_util.dart';
 import 'package:photos/utils/crypto_util.dart';
 import 'package:photos/utils/date_time_util.dart';
 import 'package:photos/utils/date_time_util.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/dialog_util.dart';
@@ -50,6 +50,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
     return Scaffold(
     return Scaffold(
       backgroundColor: Theme.of(context).backgroundColor,
       backgroundColor: Theme.of(context).backgroundColor,
       appBar: AppBar(
       appBar: AppBar(
+        elevation: 0,
         title: Text(
         title: Text(
           "Manage link",
           "Manage link",
         ),
         ),
@@ -165,14 +166,16 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                           onChanged: (value) async {
                           onChanged: (value) async {
                             if (!value) {
                             if (!value) {
                               final choice = await showChoiceDialog(
                               final choice = await showChoiceDialog(
-                                context,
-                                'Disable downloads',
-                                'Are you sure that you want to disable the download button for files?',
-                                firstAction: 'No',
-                                secondAction: 'Yes',
-                                firstActionColor: Theme.of(context).buttonColor,
-                                secondActionColor: Colors.white,
-                              );
+                                  context,
+                                  'Disable downloads',
+                                  'Are you sure that you want to disable the download button for files?',
+                                  firstAction: 'No',
+                                  secondAction: 'Yes',
+                                  firstActionColor:
+                                      Theme.of(context).colorScheme.greenText,
+                                  secondActionColor: Theme.of(context)
+                                      .colorScheme
+                                      .inverseBackgroundColor);
                               if (choice != DialogUserChoice.secondChoice) {
                               if (choice != DialogUserChoice.secondChoice) {
                                 return;
                                 return;
                               }
                               }
@@ -200,7 +203,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
 
 
   Future<void> showPicker() async {
   Future<void> showPicker() async {
     Widget getOptionText(String text) {
     Widget getOptionText(String text) {
-      return Text(text, style: TextStyle(color: Colors.white));
+      return Text(text, style: Theme.of(context).textTheme.subtitle1);
     }
     }
 
 
     return showCupertinoModalPopup(
     return showCupertinoModalPopup(
@@ -211,7 +214,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
           children: <Widget>[
           children: <Widget>[
             Container(
             Container(
               decoration: BoxDecoration(
               decoration: BoxDecoration(
-                color: Colors.white.withOpacity(0.1),
+                color: Theme.of(context).colorScheme.cupertinoPickerTopColor,
                 border: Border(
                 border: Border(
                   bottom: BorderSide(
                   bottom: BorderSide(
                     color: Color(0xff999999),
                     color: Color(0xff999999),
@@ -223,10 +226,10 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                 children: <Widget>[
                 children: <Widget>[
                   CupertinoButton(
                   CupertinoButton(
-                    child: Text('Cancel',
-                        style: TextStyle(
-                          color: Colors.white,
-                        )),
+                    child: Text(
+                      'Cancel',
+                      style: Theme.of(context).textTheme.subtitle1,
+                    ),
                     onPressed: () {
                     onPressed: () {
                       Navigator.of(context).pop('cancel');
                       Navigator.of(context).pop('cancel');
                     },
                     },
@@ -236,10 +239,10 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                     ),
                     ),
                   ),
                   ),
                   CupertinoButton(
                   CupertinoButton(
-                    child: Text('Confirm',
-                        style: TextStyle(
-                          color: Colors.white,
-                        )),
+                    child: Text(
+                      'Confirm',
+                      style: Theme.of(context).textTheme.subtitle1,
+                    ),
                     onPressed: () async {
                     onPressed: () async {
                       int newValidTill = -1;
                       int newValidTill = -1;
                       int expireAfterInMicroseconds = _selectedExpiry.item3;
                       int expireAfterInMicroseconds = _selectedExpiry.item3;
@@ -276,7 +279,8 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
               height: 220.0,
               height: 220.0,
               color: Color(0xfff7f7f7),
               color: Color(0xfff7f7f7),
               child: CupertinoPicker(
               child: CupertinoPicker(
-                backgroundColor: Colors.black.withOpacity(0.95),
+                backgroundColor:
+                    Theme.of(context).backgroundColor.withOpacity(0.95),
                 children:
                 children:
                     _expiryOptions.map((e) => getOptionText(e.item2)).toList(),
                     _expiryOptions.map((e) => getOptionText(e.item2)).toList(),
                 onSelectedItemChanged: (value) {
                 onSelectedItemChanged: (value) {
@@ -305,7 +309,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
       minTime: DateTime.now(),
       minTime: DateTime.now(),
       currentTime: DateTime.now(),
       currentTime: DateTime.now(),
       locale: LocaleType.en,
       locale: LocaleType.en,
-      theme: kDatePickerTheme,
+      theme: Theme.of(context).colorScheme.dateTimePickertheme,
     );
     );
     if (dateResult == null) {
     if (dateResult == null) {
       return null;
       return null;
@@ -315,7 +319,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
       showTitleActions: true,
       showTitleActions: true,
       currentTime: dateResult,
       currentTime: dateResult,
       locale: LocaleType.en,
       locale: LocaleType.en,
-      theme: kDatePickerTheme,
+      theme: Theme.of(context).colorScheme.dateTimePickertheme,
     );
     );
     if (dateWithTimeResult == null) {
     if (dateWithTimeResult == null) {
       return null;
       return null;
@@ -365,23 +369,15 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
               ),
               ),
               actions: <Widget>[
               actions: <Widget>[
                 TextButton(
                 TextButton(
-                  child: Text(
-                    'Cancel',
-                    style: TextStyle(
-                      color: Colors.white,
-                    ),
-                  ),
+                  child: Text('Cancel',
+                      style: Theme.of(context).textTheme.subtitle2),
                   onPressed: () {
                   onPressed: () {
                     Navigator.pop(context, 'cancel');
                     Navigator.pop(context, 'cancel');
                   },
                   },
                 ),
                 ),
                 TextButton(
                 TextButton(
-                  child: Text(
-                    'ok',
-                    style: TextStyle(
-                      color: Colors.white,
-                    ),
-                  ),
+                  child:
+                      Text('Ok', style: Theme.of(context).textTheme.subtitle2),
                   onPressed: () {
                   onPressed: () {
                     if (_textFieldController.text.trim().isEmpty) {
                     if (_textFieldController.text.trim().isEmpty) {
                       return;
                       return;
@@ -454,7 +450,8 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
   Future<void> _showDeviceLimitPicker() async {
   Future<void> _showDeviceLimitPicker() async {
     List<Text> options = [];
     List<Text> options = [];
     for (int i = 50; i > 0; i--) {
     for (int i = 50; i > 0; i--) {
-      options.add(Text(i.toString(), style: TextStyle(color: Colors.white)));
+      options.add(
+          Text(i.toString(), style: Theme.of(context).textTheme.subtitle1));
     }
     }
     return showCupertinoModalPopup(
     return showCupertinoModalPopup(
       context: context,
       context: context,
@@ -464,7 +461,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
           children: <Widget>[
           children: <Widget>[
             Container(
             Container(
               decoration: BoxDecoration(
               decoration: BoxDecoration(
-                color: Colors.white.withOpacity(0.1),
+                color: Theme.of(context).colorScheme.cupertinoPickerTopColor,
                 border: Border(
                 border: Border(
                   bottom: BorderSide(
                   bottom: BorderSide(
                     color: Color(0xff999999),
                     color: Color(0xff999999),
@@ -476,10 +473,10 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                 children: <Widget>[
                 children: <Widget>[
                   CupertinoButton(
                   CupertinoButton(
-                    child: Text('Cancel',
-                        style: TextStyle(
-                          color: Colors.white,
-                        )),
+                    child: Text(
+                      'Cancel',
+                      style: Theme.of(context).textTheme.subtitle1,
+                    ),
                     onPressed: () {
                     onPressed: () {
                       Navigator.of(context).pop('cancel');
                       Navigator.of(context).pop('cancel');
                     },
                     },
@@ -489,10 +486,10 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                     ),
                     ),
                   ),
                   ),
                   CupertinoButton(
                   CupertinoButton(
-                    child: Text('Confirm',
-                        style: TextStyle(
-                          color: Colors.white,
-                        )),
+                    child: Text(
+                      'Confirm',
+                      style: Theme.of(context).textTheme.subtitle1,
+                    ),
                     onPressed: () async {
                     onPressed: () async {
                       await _updateUrlSettings(context, {
                       await _updateUrlSettings(context, {
                         'deviceLimit': int.tryParse(
                         'deviceLimit': int.tryParse(
@@ -513,7 +510,8 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
               height: 220.0,
               height: 220.0,
               color: Color(0xfff7f7f7),
               color: Color(0xfff7f7f7),
               child: CupertinoPicker(
               child: CupertinoPicker(
-                backgroundColor: Colors.black.withOpacity(0.95),
+                backgroundColor:
+                    Theme.of(context).backgroundColor.withOpacity(0.95),
                 children: options,
                 children: options,
                 onSelectedItemChanged: (value) {
                 onSelectedItemChanged: (value) {
                   _selectedDeviceLimitIndex = value;
                   _selectedDeviceLimitIndex = value;

+ 1 - 1
lib/ui/settings/support_section_widget.dart

@@ -72,7 +72,7 @@ class SupportSectionWidget extends StatelessWidget {
           onDoubleTap: () async {
           onDoubleTap: () async {
             final zipFilePath = await getZippedLogsFile(context);
             final zipFilePath = await getZippedLogsFile(context);
             await shareLogs(context, "bug@ente.io", zipFilePath);
             await shareLogs(context, "bug@ente.io", zipFilePath);
-        },
+          },
           child: SettingsTextItem(
           child: SettingsTextItem(
               text: "Report bug 🐞", icon: Icons.navigate_next),
               text: "Report bug 🐞", icon: Icons.navigate_next),
         ),
         ),

+ 1 - 0
pubspec.yaml

@@ -11,6 +11,7 @@ description: ente photos application
 # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
 # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
 # Read more about iOS versioning at
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
+
 version: 0.5.33+313
 version: 0.5.33+313
 
 
 environment:
 environment: