mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Refactor: extract widget
This commit is contained in:
parent
2c26908237
commit
9c2a9cb0ad
1 changed files with 50 additions and 55 deletions
|
@ -112,73 +112,63 @@ class _SettingsState extends State<Settings> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.palette_outlined),
|
leading: const Icon(Icons.palette_outlined),
|
||||||
label: L10n.global().settingsThemeTitle,
|
label: L10n.global().settingsThemeTitle,
|
||||||
description: L10n.global().settingsThemeDescription,
|
description: L10n.global().settingsThemeDescription,
|
||||||
builder: () => const ThemeSettings(),
|
pageBuilder: () => const ThemeSettings(),
|
||||||
),
|
),
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.local_offer_outlined),
|
leading: const Icon(Icons.local_offer_outlined),
|
||||||
label: L10n.global().settingsMetadataTitle,
|
label: L10n.global().settingsMetadataTitle,
|
||||||
builder: () => const MetadataSettings(),
|
pageBuilder: () => const MetadataSettings(),
|
||||||
),
|
),
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.image_outlined),
|
leading: const Icon(Icons.image_outlined),
|
||||||
label: L10n.global().photosTabLabel,
|
label: L10n.global().photosTabLabel,
|
||||||
description: L10n.global().settingsPhotosDescription,
|
description: L10n.global().settingsPhotosDescription,
|
||||||
builder: () => _PhotosSettings(account: widget.account),
|
pageBuilder: () => _PhotosSettings(account: widget.account),
|
||||||
),
|
),
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.grid_view_outlined),
|
leading: const Icon(Icons.grid_view_outlined),
|
||||||
label: L10n.global().collectionsTooltip,
|
label: L10n.global().collectionsTooltip,
|
||||||
builder: () => _AlbumSettings(),
|
pageBuilder: () => _AlbumSettings(),
|
||||||
),
|
),
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.view_carousel_outlined),
|
leading: const Icon(Icons.view_carousel_outlined),
|
||||||
label: L10n.global().settingsViewerTitle,
|
label: L10n.global().settingsViewerTitle,
|
||||||
description: L10n.global().settingsViewerDescription,
|
description: L10n.global().settingsViewerDescription,
|
||||||
builder: () => _ViewerSettings(),
|
pageBuilder: () => _ViewerSettings(),
|
||||||
),
|
),
|
||||||
if (features.isSupportEnhancement)
|
if (features.isSupportEnhancement)
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.auto_fix_high_outlined),
|
leading: const Icon(Icons.auto_fix_high_outlined),
|
||||||
label: L10n.global().settingsImageEditTitle,
|
label: L10n.global().settingsImageEditTitle,
|
||||||
description: L10n.global().settingsImageEditDescription,
|
description: L10n.global().settingsImageEditDescription,
|
||||||
builder: () => const EnhancementSettings(),
|
pageBuilder: () => const EnhancementSettings(),
|
||||||
),
|
),
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.emoji_symbols_outlined),
|
leading: const Icon(Icons.emoji_symbols_outlined),
|
||||||
label: L10n.global().settingsMiscellaneousTitle,
|
label: L10n.global().settingsMiscellaneousTitle,
|
||||||
builder: () => const _MiscSettings(),
|
pageBuilder: () => const _MiscSettings(),
|
||||||
),
|
),
|
||||||
// if (_enabledExperiments.isNotEmpty)
|
// if (_enabledExperiments.isNotEmpty)
|
||||||
// _buildSubSettings(
|
// _SubPageItem(
|
||||||
// context,
|
|
||||||
// leading: const Icon(Icons.science_outlined),
|
// leading: const Icon(Icons.science_outlined),
|
||||||
// label: L10n.global().settingsExperimentalTitle,
|
// label: L10n.global().settingsExperimentalTitle,
|
||||||
// description: L10n.global().settingsExperimentalDescription,
|
// description: L10n.global().settingsExperimentalDescription,
|
||||||
// builder: () => _ExperimentalSettings(),
|
// pageBuilder: () => _ExperimentalSettings(),
|
||||||
// ),
|
// ),
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.warning_amber),
|
leading: const Icon(Icons.warning_amber),
|
||||||
label: L10n.global().settingsExpertTitle,
|
label: L10n.global().settingsExpertTitle,
|
||||||
builder: () => const ExpertSettings(),
|
pageBuilder: () => const ExpertSettings(),
|
||||||
),
|
),
|
||||||
if (_isShowDevSettings)
|
if (_isShowDevSettings)
|
||||||
_buildSubSettings(
|
_SubPageItem(
|
||||||
context,
|
|
||||||
leading: const Icon(Icons.code_outlined),
|
leading: const Icon(Icons.code_outlined),
|
||||||
label: "Developer options",
|
label: "Developer options",
|
||||||
builder: () => const DeveloperSettings(),
|
pageBuilder: () => const DeveloperSettings(),
|
||||||
),
|
),
|
||||||
SettingsListCaption(
|
SettingsListCaption(
|
||||||
label: L10n.global().settingsAboutSectionTitle,
|
label: L10n.global().settingsAboutSectionTitle,
|
||||||
|
@ -235,31 +225,6 @@ class _SettingsState extends State<Settings> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSubSettings(
|
|
||||||
BuildContext context, {
|
|
||||||
Widget? leading,
|
|
||||||
required String label,
|
|
||||||
String? description,
|
|
||||||
required Widget Function() builder,
|
|
||||||
}) {
|
|
||||||
return ListTile(
|
|
||||||
leading: leading == null
|
|
||||||
? null
|
|
||||||
: ListTileCenterLeading(
|
|
||||||
child: leading,
|
|
||||||
),
|
|
||||||
title: Text(label),
|
|
||||||
subtitle: description == null ? null : Text(description),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => builder(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onCaptureLogChanged(BuildContext context, bool value) async {
|
Future<void> _onCaptureLogChanged(BuildContext context, bool value) async {
|
||||||
if (value) {
|
if (value) {
|
||||||
final result = await showDialog<bool>(
|
final result = await showDialog<bool>(
|
||||||
|
@ -319,6 +284,36 @@ class _SettingsState extends State<Settings> {
|
||||||
static const String _translationUrl = "https://bit.ly/3NwmdSw";
|
static const String _translationUrl = "https://bit.ly/3NwmdSw";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _SubPageItem extends StatelessWidget {
|
||||||
|
const _SubPageItem({
|
||||||
|
this.leading,
|
||||||
|
required this.label,
|
||||||
|
this.description,
|
||||||
|
required this.pageBuilder,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: leading == null ? null : ListTileCenterLeading(child: leading!),
|
||||||
|
title: Text(label),
|
||||||
|
subtitle: description == null ? null : Text(description!),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => pageBuilder(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Widget? leading;
|
||||||
|
final String label;
|
||||||
|
final String? description;
|
||||||
|
final Widget Function() pageBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
class _PhotosSettings extends StatefulWidget {
|
class _PhotosSettings extends StatefulWidget {
|
||||||
const _PhotosSettings({
|
const _PhotosSettings({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
|
Loading…
Reference in a new issue