Feat: Lagert die Versionsnummer in eine eigene Klasse aus und macht Settings zu einem StatelessWidget
This commit is contained in:
@@ -1,75 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
import 'account_list.dart';
|
||||
import 'recurring_transaction_list.dart';
|
||||
import 'version_number.dart';
|
||||
|
||||
/// Eine Widget-Klasse, die die Einstellungsseite der Anwendung darstellt.
|
||||
class Settings extends StatefulWidget {
|
||||
class Settings extends StatelessWidget {
|
||||
/// Erstellt eine neue Instanz dieser Klasse.
|
||||
const Settings({super.key});
|
||||
|
||||
@override
|
||||
State<Settings> createState() => _SettingsState();
|
||||
}
|
||||
Widget build(final BuildContext context) => const Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Einstellungen',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
|
||||
class _SettingsState extends State<Settings> {
|
||||
@override
|
||||
Widget build(final BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
AccountList(),
|
||||
SizedBox(height: 24),
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'Einstellungen',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
const AccountList(),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
const RecurringTransactionList(),
|
||||
const SizedBox(height: 8),
|
||||
_versionNumber(theme),
|
||||
],
|
||||
),
|
||||
RecurringTransactionList(),
|
||||
SizedBox(height: 8),
|
||||
VersionNumber(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _versionNumber(final ThemeData theme) {
|
||||
final Future<PackageInfo> packageInfo = PackageInfo.fromPlatform();
|
||||
|
||||
return Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: FutureBuilder(
|
||||
future: packageInfo,
|
||||
builder:
|
||||
(
|
||||
final BuildContext context,
|
||||
final AsyncSnapshot<PackageInfo> snapshot,
|
||||
) {
|
||||
if (snapshot.hasData) {
|
||||
return Text(
|
||||
'${snapshot.data?.version}+${snapshot.data?.buildNumber}',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withAlpha(
|
||||
(0.6 * 255).round(),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user