From c74d4307471156cfa5795991ccf8f359c27c7f79 Mon Sep 17 00:00:00 2001
From: Ming Ming <nkming2@gmail.com>
Date: Thu, 16 Sep 2021 00:29:37 +0800
Subject: [PATCH] Accent color is no longer used in flutter 2.5

---
 lib/widget/album_browser.dart         |  4 +-
 lib/widget/album_importer.dart        | 15 ++----
 lib/widget/archive_browser.dart       |  4 +-
 lib/widget/dir_picker_mixin.dart      | 76 ++++++++++++---------------
 lib/widget/dynamic_album_browser.dart |  4 +-
 lib/widget/home_albums.dart           |  4 +-
 lib/widget/home_photos.dart           |  4 +-
 lib/widget/pending_albums.dart        |  4 +-
 lib/widget/people_browser.dart        |  4 +-
 lib/widget/person_browser.dart        |  4 +-
 lib/widget/settings.dart              |  2 +-
 lib/widget/trashbin_browser.dart      |  4 +-
 12 files changed, 68 insertions(+), 61 deletions(-)

diff --git a/lib/widget/album_browser.dart b/lib/widget/album_browser.dart
index d4df4152..d00343e0 100644
--- a/lib/widget/album_browser.dart
+++ b/lib/widget/album_browser.dart
@@ -222,7 +222,9 @@ class _AlbumBrowserState extends State<AlbumBrowser>
       context,
       child: Theme(
         data: Theme.of(context).copyWith(
-          accentColor: AppTheme.getOverscrollIndicatorColor(context),
+          colorScheme: Theme.of(context).colorScheme.copyWith(
+                secondary: AppTheme.getOverscrollIndicatorColor(context),
+              ),
         ),
         child: content,
       ),
diff --git a/lib/widget/album_importer.dart b/lib/widget/album_importer.dart
index c976156d..111bb5e5 100644
--- a/lib/widget/album_importer.dart
+++ b/lib/widget/album_importer.dart
@@ -156,16 +156,11 @@ class _AlbumImporterState extends State<AlbumImporter> {
   }
 
   Widget _buildList(BuildContext context, ListImportableAlbumBlocState state) {
-    return Theme(
-      data: Theme.of(context).copyWith(
-        accentColor: AppTheme.getOverscrollIndicatorColor(context),
-      ),
-      child: ListView.separated(
-        itemBuilder: (context, index) =>
-            _buildItem(context, _backingFiles[index]),
-        separatorBuilder: (context, index) => const Divider(),
-        itemCount: _backingFiles.length,
-      ),
+    return ListView.separated(
+      itemBuilder: (context, index) =>
+          _buildItem(context, _backingFiles[index]),
+      separatorBuilder: (context, index) => const Divider(),
+      itemCount: _backingFiles.length,
     );
   }
 
diff --git a/lib/widget/archive_browser.dart b/lib/widget/archive_browser.dart
index 447cbf53..2ed91365 100644
--- a/lib/widget/archive_browser.dart
+++ b/lib/widget/archive_browser.dart
@@ -119,7 +119,9 @@ class _ArchiveBrowserState extends State<ArchiveBrowser>
             context,
             child: Theme(
               data: Theme.of(context).copyWith(
-                accentColor: AppTheme.getOverscrollIndicatorColor(context),
+                colorScheme: Theme.of(context).colorScheme.copyWith(
+                      secondary: AppTheme.getOverscrollIndicatorColor(context),
+                    ),
               ),
               child: CustomScrollView(
                 slivers: [
diff --git a/lib/widget/dir_picker_mixin.dart b/lib/widget/dir_picker_mixin.dart
index 041b51be..d202a310 100644
--- a/lib/widget/dir_picker_mixin.dart
+++ b/lib/widget/dir_picker_mixin.dart
@@ -12,7 +12,6 @@ import 'package:nc_photos/entity/file.dart';
 import 'package:nc_photos/exception_util.dart' as exception_util;
 import 'package:nc_photos/k.dart' as k;
 import 'package:nc_photos/snack_bar_manager.dart';
-import 'package:nc_photos/theme.dart';
 import 'package:path/path.dart' as path;
 
 mixin DirPickerMixin<T extends StatefulWidget> on State<T> {
@@ -78,47 +77,42 @@ mixin DirPickerMixin<T extends StatefulWidget> on State<T> {
 
   Widget _buildList(BuildContext context, LsDirBlocState state) {
     final isTopLevel = _currentPath == getPickerRoot();
-    return Theme(
-      data: Theme.of(context).copyWith(
-        accentColor: AppTheme.getOverscrollIndicatorColor(context),
+    return AnimatedSwitcher(
+      duration: k.animationDurationNormal,
+      // see AnimatedSwitcher.defaultLayoutBuilder
+      layoutBuilder: (currentChild, previousChildren) => Stack(
+        children: <Widget>[
+          ...previousChildren,
+          if (currentChild != null) currentChild,
+        ],
+        alignment: Alignment.topLeft,
       ),
-      child: AnimatedSwitcher(
-        duration: k.animationDurationNormal,
-        // see AnimatedSwitcher.defaultLayoutBuilder
-        layoutBuilder: (currentChild, previousChildren) => Stack(
-          children: <Widget>[
-            ...previousChildren,
-            if (currentChild != null) currentChild,
-          ],
-          alignment: Alignment.topLeft,
-        ),
-        child: ListView.separated(
-          key: Key(_currentPath),
-          itemBuilder: (context, index) {
-            if (!isTopLevel && index == 0) {
-              return ListTile(
-                dense: true,
-                leading: const SizedBox(width: 24),
-                title: Text(L10n.global().rootPickerNavigateUpItemText),
-                onTap: () {
-                  try {
-                    _navigateInto(File(path: path.dirname(_currentPath)));
-                  } catch (e) {
-                    SnackBarManager().showSnackBar(SnackBar(
-                      content: Text(exception_util.toUserString(e)),
-                      duration: k.snackBarDurationNormal,
-                    ));
-                  }
-                },
-              );
-            } else {
-              return _buildItem(
-                  context, state.items[index - (isTopLevel ? 0 : 1)]);
-            }
-          },
-          separatorBuilder: (context, index) => const Divider(),
-          itemCount: state.items.length + (isTopLevel ? 0 : 1),
-        ),
+      child: ListView.separated(
+        key: Key(_currentPath),
+        itemBuilder: (context, index) {
+          if (!isTopLevel && index == 0) {
+            return ListTile(
+              dense: true,
+              leading: const SizedBox(width: 24),
+              title: Text(L10n.global().rootPickerNavigateUpItemText),
+              onTap: () {
+                try {
+                  _navigateInto(File(path: path.dirname(_currentPath)));
+                } catch (e) {
+                  SnackBarManager().showSnackBar(SnackBar(
+                    content: Text(exception_util.toUserString(e)),
+                    duration: k.snackBarDurationNormal,
+                  ));
+                }
+              },
+            );
+          } else {
+            return _buildItem(
+                context, state.items[index - (isTopLevel ? 0 : 1)]);
+          }
+        },
+        separatorBuilder: (context, index) => const Divider(),
+        itemCount: state.items.length + (isTopLevel ? 0 : 1),
       ),
     );
   }
diff --git a/lib/widget/dynamic_album_browser.dart b/lib/widget/dynamic_album_browser.dart
index a5f50b12..c708bab6 100644
--- a/lib/widget/dynamic_album_browser.dart
+++ b/lib/widget/dynamic_album_browser.dart
@@ -226,7 +226,9 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
       context,
       child: Theme(
         data: Theme.of(context).copyWith(
-          accentColor: AppTheme.getOverscrollIndicatorColor(context),
+          colorScheme: Theme.of(context).colorScheme.copyWith(
+                secondary: AppTheme.getOverscrollIndicatorColor(context),
+              ),
         ),
         child: CustomScrollView(
           slivers: [
diff --git a/lib/widget/home_albums.dart b/lib/widget/home_albums.dart
index aa73503b..041d15e2 100644
--- a/lib/widget/home_albums.dart
+++ b/lib/widget/home_albums.dart
@@ -109,7 +109,9 @@ class _HomeAlbumsState extends State<HomeAlbums>
           context,
           child: Theme(
             data: Theme.of(context).copyWith(
-              accentColor: AppTheme.getOverscrollIndicatorColor(context),
+              colorScheme: Theme.of(context).colorScheme.copyWith(
+                    secondary: AppTheme.getOverscrollIndicatorColor(context),
+                  ),
             ),
             child: CustomScrollView(
               slivers: [
diff --git a/lib/widget/home_photos.dart b/lib/widget/home_photos.dart
index 2109dde3..2eff2ee2 100644
--- a/lib/widget/home_photos.dart
+++ b/lib/widget/home_photos.dart
@@ -119,7 +119,9 @@ class _HomePhotosState extends State<HomePhotos>
             context,
             child: Theme(
               data: Theme.of(context).copyWith(
-                accentColor: AppTheme.getOverscrollIndicatorColor(context),
+                colorScheme: Theme.of(context).colorScheme.copyWith(
+                      secondary: AppTheme.getOverscrollIndicatorColor(context),
+                    ),
               ),
               child: DraggableScrollbar.semicircle(
                 controller: _scrollController,
diff --git a/lib/widget/pending_albums.dart b/lib/widget/pending_albums.dart
index 2ec7fdec..58d2ce2b 100644
--- a/lib/widget/pending_albums.dart
+++ b/lib/widget/pending_albums.dart
@@ -101,7 +101,9 @@ class _PendingAlbumsState extends State<PendingAlbums> {
         children: [
           Theme(
             data: Theme.of(context).copyWith(
-              accentColor: AppTheme.getOverscrollIndicatorColor(context),
+              colorScheme: Theme.of(context).colorScheme.copyWith(
+                    secondary: AppTheme.getOverscrollIndicatorColor(context),
+                  ),
             ),
             child: CustomScrollView(
               slivers: [
diff --git a/lib/widget/people_browser.dart b/lib/widget/people_browser.dart
index f53c14a9..061945a4 100644
--- a/lib/widget/people_browser.dart
+++ b/lib/widget/people_browser.dart
@@ -129,7 +129,9 @@ class _PeopleBrowserState extends State<PeopleBrowser> {
         children: [
           Theme(
             data: Theme.of(context).copyWith(
-              accentColor: AppTheme.getOverscrollIndicatorColor(context),
+              colorScheme: Theme.of(context).colorScheme.copyWith(
+                    secondary: AppTheme.getOverscrollIndicatorColor(context),
+                  ),
             ),
             child: CustomScrollView(
               slivers: [
diff --git a/lib/widget/person_browser.dart b/lib/widget/person_browser.dart
index 2bd5453a..95d59121 100644
--- a/lib/widget/person_browser.dart
+++ b/lib/widget/person_browser.dart
@@ -128,7 +128,9 @@ class _PersonBrowserState extends State<PersonBrowser>
         context,
         child: Theme(
           data: Theme.of(context).copyWith(
-            accentColor: AppTheme.getOverscrollIndicatorColor(context),
+            colorScheme: Theme.of(context).colorScheme.copyWith(
+                  secondary: AppTheme.getOverscrollIndicatorColor(context),
+                ),
           ),
           child: CustomScrollView(
             slivers: [
diff --git a/lib/widget/settings.dart b/lib/widget/settings.dart
index a521a738..3952cab2 100644
--- a/lib/widget/settings.dart
+++ b/lib/widget/settings.dart
@@ -182,7 +182,7 @@ class _SettingsState extends State<Settings> {
       child: Text(
         label,
         style: TextStyle(
-          color: Theme.of(context).accentColor,
+          color: Theme.of(context).colorScheme.secondary,
         ),
       ),
     );
diff --git a/lib/widget/trashbin_browser.dart b/lib/widget/trashbin_browser.dart
index dd1bbd77..d7fb4fd6 100644
--- a/lib/widget/trashbin_browser.dart
+++ b/lib/widget/trashbin_browser.dart
@@ -121,7 +121,9 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
             context,
             child: Theme(
               data: Theme.of(context).copyWith(
-                accentColor: AppTheme.getOverscrollIndicatorColor(context),
+                colorScheme: Theme.of(context).colorScheme.copyWith(
+                      secondary: AppTheme.getOverscrollIndicatorColor(context),
+                    ),
               ),
               child: CustomScrollView(
                 slivers: [