Jelajahi Sumber

Made a resuable button with linear gradient and bigger font for 'today'

ashilkn 3 tahun lalu
induk
melakukan
044471eaa1

+ 0 - 6
lib/ente_theme_data.dart

@@ -20,12 +20,6 @@ extension CustomColorScheme on ColorScheme {
   Color get fabTextOrIconColor =>
   Color get fabTextOrIconColor =>
       brightness == Brightness.light ? Colors.white : Colors.white;
       brightness == Brightness.light ? Colors.white : Colors.white;
 
 
-  // todo: use brightness == Brightness.light for changing color for dark/light theme
-  ButtonStyle get primaryActionButtonStyle => buildElevatedButtonThemeData(
-        onPrimary: Colors.white,
-        primary: Color.fromRGBO(29, 185, 84, 1.0),
-      ).style;
-
   // todo: use brightness == Brightness.light for changing color for dark/light theme
   // todo: use brightness == Brightness.light for changing color for dark/light theme
   ButtonStyle get optionalActionButtonStyle => buildElevatedButtonThemeData(
   ButtonStyle get optionalActionButtonStyle => buildElevatedButtonThemeData(
         onPrimary: Colors.black87,
         onPrimary: Colors.black87,

+ 29 - 0
lib/ui/common/gradientButton.dart

@@ -0,0 +1,29 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
+
+class GradientButton extends StatelessWidget {
+  final Widget child;
+  final List<Color> linearGradientColors;
+  final Function onTap;
+
+  GradientButton({this.child, this.linearGradientColors, this.onTap});
+
+  @override
+  Widget build(BuildContext context) {
+    return InkWell(
+      onTap: onTap,
+      child: Container(
+        height: 56,
+        decoration: BoxDecoration(
+          gradient: LinearGradient(
+            begin: Alignment(0.1, -0.9),
+            end: Alignment(-0.6, 0.9),
+            colors: linearGradientColors,
+          ),
+          borderRadius: BorderRadius.circular(8),
+        ),
+        child: child,
+      ),
+    );
+  }
+}

+ 37 - 38
lib/ui/gallery_footer_widget.dart

@@ -4,53 +4,52 @@ import 'package:photo_manager/photo_manager.dart';
 import 'package:photos/ente_theme_data.dart';
 import 'package:photos/ente_theme_data.dart';
 import 'package:photos/services/local_sync_service.dart';
 import 'package:photos/services/local_sync_service.dart';
 import 'package:photos/ui/backup_folder_selection_page.dart';
 import 'package:photos/ui/backup_folder_selection_page.dart';
+import 'package:photos/ui/common/gradientButton.dart';
 import 'package:photos/utils/navigation_util.dart';
 import 'package:photos/utils/navigation_util.dart';
+import 'package:sqflite/utils/utils.dart';
 
 
 class GalleryFooterWidget extends StatelessWidget {
 class GalleryFooterWidget extends StatelessWidget {
   const GalleryFooterWidget({Key key}) : super(key: key);
   const GalleryFooterWidget({Key key}) : super(key: key);
 
 
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    return Column(
-      children: [
-        Padding(padding: EdgeInsets.all(6)),
-        Divider(
-          height: 1,
-        ),
-        Container(
-          padding: EdgeInsets.fromLTRB(20, 24, 20, 72),
-          child: ElevatedButton(
-            style: Theme.of(context).colorScheme.primaryActionButtonStyle,
-            onPressed: () async {
-              if (LocalSyncService.instance.hasGrantedLimitedPermissions()) {
-                await PhotoManager.presentLimited();
-              } else {
-                routeToPage(
-                  context,
-                  BackupFolderSelectionPage(
-                    buttonText: "preserve",
-                  ),
-                );
-              }
-            },
-            child: Row(
-              mainAxisAlignment: MainAxisAlignment.center,
-              crossAxisAlignment: CrossAxisAlignment.center,
-              //mainAxisSize: MainAxisSize.min,
-              children: [
-                Icon(
-                  Icons.cloud_upload,
-                  color: Theme.of(context).backgroundColor,
-                ),
-                Padding(padding: EdgeInsets.all(6)),
-                Text(
-                  "Preserve more",
-                ),
-              ],
+    return Padding(
+      padding: const EdgeInsets.fromLTRB(20, 24, 20, 80),
+      child: GradientButton(
+        child: Row(
+          mainAxisAlignment: MainAxisAlignment.center,
+          crossAxisAlignment: CrossAxisAlignment.center,
+          //mainAxisSize: MainAxisSize.min,
+          children: [
+            Icon(
+              Icons.cloud_upload_outlined,
+              color: Colors.white,
             ),
             ),
-          ),
+            Padding(padding: EdgeInsets.all(6)),
+            Text("Preserve more",
+                style: Theme.of(context)
+                    .textTheme
+                    .headline6
+                    .copyWith(color: Colors.white)),
+          ],
         ),
         ),
-      ],
+        linearGradientColors: const [
+          Color(0xFF2CD267),
+          Color(0xFF1DB954),
+        ],
+        onTap: () async {
+          if (LocalSyncService.instance.hasGrantedLimitedPermissions()) {
+            await PhotoManager.presentLimited();
+          } else {
+            routeToPage(
+              context,
+              BackupFolderSelectionPage(
+                buttonText: "preserve",
+              ),
+            );
+          }
+        },
+      ),
     );
     );
   }
   }
 }
 }

+ 5 - 3
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -89,9 +89,11 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
           fileDate.day == galleryDate.day;
           fileDate.day == galleryDate.day;
     });
     });
     if (filesUpdatedThisDay.isNotEmpty) {
     if (filesUpdatedThisDay.isNotEmpty) {
-      _logger.info(filesUpdatedThisDay.length.toString() +
-          " files were updated on " +
-          getDayTitle(galleryDate.microsecondsSinceEpoch));
+      _logger.info(
+        filesUpdatedThisDay.length.toString() +
+            " files were updated on " +
+            getDayTitle(galleryDate.microsecondsSinceEpoch),
+      );
       if (event.type == EventType.addedOrUpdated) {
       if (event.type == EventType.addedOrUpdated) {
         final dayStartTime =
         final dayStartTime =
             DateTime(galleryDate.year, galleryDate.month, galleryDate.day);
             DateTime(galleryDate.year, galleryDate.month, galleryDate.day);

+ 9 - 10
lib/utils/date_time_util.dart

@@ -163,16 +163,15 @@ bool isLeapYear(DateTime dateTime) {
 
 
 Widget getDayWidget(BuildContext context, int timestamp) {
 Widget getDayWidget(BuildContext context, int timestamp) {
   return Container(
   return Container(
-    padding: const EdgeInsets.fromLTRB(10, 8, 0, 10),
-    alignment: Alignment.centerLeft,
-    child: Text(
-      getDayTitle(timestamp),
-      style: TextStyle(
-        fontSize: 14,
-        color: Theme.of(context).colorScheme.onSurface.withOpacity(0.85),
-      ),
-    ),
-  );
+      padding: const EdgeInsets.fromLTRB(10, 14, 0, 12),
+      alignment: Alignment.centerLeft,
+      child: Text(getDayTitle(timestamp),
+          style: getDayTitle(timestamp) == "Today"
+              ? Theme.of(context).textTheme.headline5
+              : Theme.of(context).textTheme.caption.copyWith(
+                  fontSize: 16,
+                  fontWeight: FontWeight.w600,
+                  fontFamily: 'Inter-SemiBold')));
 }
 }
 
 
 String getDayTitle(int timestamp) {
 String getDayTitle(int timestamp) {