mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(mobile): use colorScheme colors - reduce code repetitions
This commit is contained in:
parent
aacecd3b1c
commit
339daab182
2 changed files with 41 additions and 47 deletions
|
|
@ -80,10 +80,6 @@ void main() async {
|
||||||
stackTrace: stackTrace.toString(),
|
stackTrace: stackTrace.toString(),
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
primarySwatch: Colors.red,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ class ErrorDisplayScreen extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
@ -37,13 +39,13 @@ class ErrorDisplayScreen extends StatelessWidget {
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 24,
|
width: 24,
|
||||||
height: 24,
|
height: 24,
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.red,
|
color: theme.colorScheme.error,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: const Icon(
|
child: Icon(
|
||||||
Icons.error,
|
Icons.error,
|
||||||
color: Colors.white,
|
color: theme.colorScheme.onError,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -53,22 +55,22 @@ class ErrorDisplayScreen extends StatelessWidget {
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
// Error title
|
// Error title
|
||||||
const Text(
|
Text(
|
||||||
'Initialization Failed',
|
'Initialization Failed',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 28,
|
fontSize: 28,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
color: theme.colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// Error message
|
// Error message
|
||||||
const Text(
|
Text(
|
||||||
'Failed to start due to an error during initialization.',
|
'Failed to start due to an error during initialization.',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.grey,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
|
@ -80,9 +82,9 @@ class ErrorDisplayScreen extends StatelessWidget {
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[900],
|
color: theme.colorScheme.surfaceContainer,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
border: Border.all(color: Colors.red.withValues(alpha: 0.3)),
|
border: Border.all(color: theme.colorScheme.error),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|
@ -90,44 +92,38 @@ class ErrorDisplayScreen extends StatelessWidget {
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Text(
|
||||||
'Error Details:',
|
'Error Details:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.red,
|
color: theme.colorScheme.error,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
String errorDetails;
|
||||||
try {
|
try {
|
||||||
final packageInfo = await PackageInfo.fromPlatform();
|
final packageInfo = await PackageInfo.fromPlatform();
|
||||||
final appVersion = '${packageInfo.version} build.${packageInfo.buildNumber}';
|
final appVersion = '${packageInfo.version} build.${packageInfo.buildNumber}';
|
||||||
final errorDetails = 'App Version: $appVersion\n\nError: $error\n\nStack Trace:\n$stackTrace';
|
errorDetails = 'App Version: $appVersion\n\nError: $error\n\nStack Trace:\n$stackTrace';
|
||||||
Clipboard.setData(ClipboardData(text: errorDetails)).then((_) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
content: Text('Error details copied to clipboard'),
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Fallback if package info fails
|
// Fallback if package info fails
|
||||||
final errorDetails = 'Error: $error\n\nStack Trace:\n$stackTrace';
|
errorDetails = 'Error: $error\n\nStack Trace:\n$stackTrace';
|
||||||
|
}
|
||||||
|
|
||||||
Clipboard.setData(ClipboardData(text: errorDetails)).then((_) {
|
Clipboard.setData(ClipboardData(text: errorDetails)).then((_) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
SnackBar(
|
||||||
content: Text('Error details copied to clipboard'),
|
content: const Text('Error details copied to clipboard'),
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: theme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: Icon(
|
||||||
Icons.copy,
|
Icons.copy,
|
||||||
color: Colors.grey,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
|
|
@ -138,35 +134,37 @@ class ErrorDisplayScreen extends StatelessWidget {
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
error,
|
error,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: theme.colorScheme.onSurface,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
ExpansionTile(
|
ExpansionTile(
|
||||||
title: const Text(
|
title: Text(
|
||||||
'Stack Trace',
|
'Stack Trace',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.orange,
|
color: theme.colorScheme.tertiary,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
tilePadding: EdgeInsets.zero,
|
tilePadding: EdgeInsets.zero,
|
||||||
|
iconColor: theme.colorScheme.onSurfaceVariant,
|
||||||
|
collapsedIconColor: theme.colorScheme.onSurfaceVariant,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withValues(alpha: 0.5),
|
color: theme.colorScheme.surfaceContainerHighest,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Text(
|
child: Text(
|
||||||
stackTrace,
|
stackTrace,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: theme.colorScheme.onSurface,
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
),
|
),
|
||||||
|
|
@ -188,11 +186,11 @@ class ErrorDisplayScreen extends StatelessWidget {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.refresh),
|
icon: const Icon(Icons.close),
|
||||||
label: const Text('Restart App'),
|
label: const Text('Close App'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: theme.colorScheme.error,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: theme.colorScheme.onError,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue