1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

chore(mobile): additional MD3 styling and refactor some code (#1741)

This commit is contained in:
Alex 2023-02-12 23:05:31 -06:00 committed by GitHub
parent d555ee737b
commit 11b2e2a6e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 97 additions and 65 deletions

View File

@ -14,11 +14,15 @@ class BackupInfoCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var isDarkMode = Theme.of(context).brightness == Brightness.dark;
return Card( return Card(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5), // if you need this borderRadius: BorderRadius.circular(20), // if you need this
side: const BorderSide( side: BorderSide(
color: Colors.black12, color: isDarkMode
? const Color.fromARGB(255, 101, 101, 101)
: Colors.black12,
width: 1, width: 1,
), ),
), ),

View File

@ -31,6 +31,7 @@ class BackupControllerPage extends HookConsumerWidget {
!hasExclusiveAccess !hasExclusiveAccess
? false ? false
: true; : true;
var isDarkMode = Theme.of(context).brightness == Brightness.dark;
useEffect( useEffect(
() { () {
@ -421,9 +422,11 @@ class BackupControllerPage extends HookConsumerWidget {
buildFolderSelectionTile() { buildFolderSelectionTile() {
return Card( return Card(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5), // if you need this borderRadius: BorderRadius.circular(20),
side: const BorderSide( side: BorderSide(
color: Colors.black12, color: isDarkMode
? const Color.fromARGB(255, 101, 101, 101)
: Colors.black12,
width: 1, width: 1,
), ),
), ),
@ -476,6 +479,69 @@ class BackupControllerPage extends HookConsumerWidget {
} }
} }
Widget buildBackupButton() {
return Padding(
padding: const EdgeInsets.only(
top: 24,
),
child: Container(
child: backupState.backupProgress == BackUpProgressEnum.inProgress
? ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.grey[50],
backgroundColor: Colors.red[300],
// padding: const EdgeInsets.all(14),
),
onPressed: () {
ref.read(backupProvider.notifier).cancelBackup();
},
child: const Text(
"backup_controller_page_cancel",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
).tr(),
)
: ElevatedButton(
onPressed: shouldBackup ? startBackup : null,
child: const Text(
"backup_controller_page_start_backup",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
).tr(),
),
),
);
}
buildBackgroundBackupInfo() {
return hasExclusiveAccess
? const SizedBox.shrink()
: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20), // if you need this
side: BorderSide(
color: isDarkMode
? const Color.fromARGB(255, 101, 101, 101)
: Colors.black12,
width: 1,
),
),
elevation: 0,
borderOnForeground: false,
child: const Padding(
padding: EdgeInsets.all(16.0),
child: Text(
"Background backup is currently running, some actions are disabled",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
);
}
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
@ -506,27 +572,7 @@ class BackupControllerPage extends HookConsumerWidget {
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
).tr(), ).tr(),
), ),
hasExclusiveAccess buildBackgroundBackupInfo(),
? const SizedBox.shrink()
: Card(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5), // if you need this
side: const BorderSide(
color: Colors.black12,
width: 1,
),
),
elevation: 0,
borderOnForeground: false,
child: const Padding(
padding: EdgeInsets.all(16.0),
child: Text(
"Background backup is currently running, some actions are disabled",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
),
buildFolderSelectionTile(), buildFolderSelectionTile(),
BackupInfoCard( BackupInfoCard(
title: "backup_controller_page_total".tr(), title: "backup_controller_page_total".tr(),
@ -552,42 +598,7 @@ class BackupControllerPage extends HookConsumerWidget {
buildStorageInformation(), buildStorageInformation(),
const Divider(), const Divider(),
const CurrentUploadingAssetInfoBox(), const CurrentUploadingAssetInfoBox(),
Padding( buildBackupButton()
padding: const EdgeInsets.only(
top: 24,
),
child: Container(
child:
backupState.backupProgress == BackUpProgressEnum.inProgress
? ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.grey[50],
backgroundColor: Colors.red[300],
// padding: const EdgeInsets.all(14),
),
onPressed: () {
ref.read(backupProvider.notifier).cancelBackup();
},
child: const Text(
"backup_controller_page_cancel",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
).tr(),
)
: ElevatedButton(
onPressed: shouldBackup ? startBackup : null,
child: const Text(
"backup_controller_page_start_backup",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
).tr(),
),
),
)
], ],
), ),
), ),

View File

@ -92,8 +92,18 @@ ThemeData immichLightTheme = ThemeData(
), ),
navigationBarTheme: NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
indicatorColor: Colors.indigo.withOpacity(0.15), indicatorColor: Colors.indigo.withOpacity(0.15),
iconTheme: MaterialStatePropertyAll(
IconThemeData(color: Colors.grey[700]),
),
backgroundColor: immichBackgroundColor, backgroundColor: immichBackgroundColor,
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
labelTextStyle: MaterialStatePropertyAll(
TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.grey[700],
),
),
), ),
); );
@ -166,10 +176,17 @@ ThemeData immichDarkTheme = ThemeData(
), ),
navigationBarTheme: NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
indicatorColor: immichDarkThemePrimaryColor.withOpacity(0.4), indicatorColor: immichDarkThemePrimaryColor.withOpacity(0.4),
iconTheme: const MaterialStatePropertyAll( iconTheme: MaterialStatePropertyAll(
IconThemeData(color: Colors.white), IconThemeData(color: Colors.grey[500]),
), ),
backgroundColor: Colors.grey[900], backgroundColor: Colors.grey[900],
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
labelTextStyle: MaterialStatePropertyAll(
TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.grey[500],
),
),
), ),
); );