page.dart 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:maxkey_flutter/maxkey/maxkey.dart';
  4. import 'package:maxkey_flutter/persistent.dart';
  5. import 'package:maxkey_flutter/utils.dart';
  6. import 'package:flutter_gen/gen_l10n/app_localizations.dart';
  7. part 'package:maxkey_flutter/pages/settings_page/components/theme_mode_setting.dart';
  8. part 'package:maxkey_flutter/pages/settings_page/components/host_setting.dart';
  9. part 'package:maxkey_flutter/pages/settings_page/components/show_log_btn.dart';
  10. class SettingsPage extends StatelessWidget {
  11. const SettingsPage({super.key});
  12. @override
  13. Widget build(BuildContext context) {
  14. return Scaffold(
  15. appBar: AppBar(title: Text(AppLocalizations.of(context)!.settingsPageTitle)),
  16. body: const SafeArea(
  17. child: Padding(
  18. padding: EdgeInsets.symmetric(horizontal: 16.0),
  19. child: Column(
  20. children: [
  21. _ThemeModeSwitch(),
  22. SizedBox(height: 8.0),
  23. _SetHostButton(),
  24. SizedBox(height: 8.0),
  25. _ShowLogBtn(),
  26. ],
  27. ),
  28. ),
  29. ),
  30. );
  31. }
  32. }
  33. class _SettingTile extends StatelessWidget {
  34. const _SettingTile({
  35. super.key,
  36. required this.title,
  37. this.desc,
  38. required this.action,
  39. this.onTap,
  40. });
  41. final String title;
  42. final String? desc;
  43. final Widget action;
  44. final void Function()? onTap;
  45. @override
  46. Widget build(BuildContext context) {
  47. final scheme = Theme.of(context).colorScheme;
  48. return ListTile(
  49. shape: RoundedRectangleBorder(
  50. borderRadius: BorderRadius.circular(8.0),
  51. ),
  52. tileColor: scheme.surfaceContainer,
  53. title: Text(title, maxLines: 1),
  54. subtitle: desc == null ? null : Text(desc!, maxLines: 2),
  55. isThreeLine: desc == null ? false : true,
  56. trailing: action,
  57. onTap: onTap,
  58. );
  59. }
  60. }