DietaryGuard/lib/screens/settings.dart
2024-08-15 21:12:23 +08:00

86 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher_string.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
@override
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
title: Text('settings'.tr),
),
body: ListView(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(16)),
child: Image.asset("assets/icon.png", width: 64, height: 64),
).paddingAll(8),
const SizedBox(height: 12),
Text(
'appName'.tr,
style: Theme.of(context).textTheme.headlineMedium,
),
Text('appDescription'.tr),
FutureBuilder(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Text('loading'.tr);
}
return Text(
'v${snapshot.data!.version} (${snapshot.data!.buildNumber})',
style: GoogleFonts.ibmPlexMono(fontSize: 12),
);
},
),
],
).paddingOnly(left: 24, right: 24, bottom: 16),
const Divider(height: 1, thickness: 0.3).paddingOnly(
bottom: 16,
top: 8,
),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
trailing: const Icon(Icons.chevron_right),
title: Text('settingsAlertSection'.tr),
onTap: () {
GoRouter.of(context).pushNamed('settingsAlert');
},
),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
trailing: const Icon(Icons.chevron_right),
title: Text('settingsDataSection'.tr),
onTap: () {
GoRouter.of(context).pushNamed('settingsDataSource');
},
),
const Divider(height: 1, thickness: 0.3)
.paddingOnly(top: 16, bottom: 8),
Center(
child: InkWell(
borderRadius: const BorderRadius.all(Radius.circular(8)),
child: Text('appCopyright'.tr, textAlign: TextAlign.center)
.paddingAll(8),
onTap: () {
launchUrlString("https://solsynth.dev");
},
),
),
],
),
),
);
}
}