mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
opt.: sync switch
This commit is contained in:
@@ -44,6 +44,7 @@ class BackupPage extends StatelessWidget {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(17),
|
||||
children: [
|
||||
_buildTip(),
|
||||
if (isMacOS || isIOS) _buildIcloud(context),
|
||||
_buildWebdav(context),
|
||||
_buildFile(context),
|
||||
@@ -51,6 +52,16 @@ class BackupPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTip() {
|
||||
return CardX(
|
||||
ListTile(
|
||||
leading: const Icon(Icons.warning),
|
||||
title: Text(l10n.attention),
|
||||
subtitle: Text(l10n.backupTip, style: UIs.textGrey),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFile(BuildContext context) {
|
||||
return CardX(
|
||||
ExpandTile(
|
||||
@@ -61,10 +72,6 @@ class BackupPage extends StatelessWidget {
|
||||
ListTile(
|
||||
title: Text(l10n.backup),
|
||||
trailing: const Icon(Icons.save),
|
||||
subtitle: Text(
|
||||
l10n.backupTip,
|
||||
style: UIs.textGrey,
|
||||
),
|
||||
onTap: () async {
|
||||
final path = await Backup.backup();
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/persistant_store.dart';
|
||||
@@ -6,7 +8,7 @@ class StoreSwitch extends StatelessWidget {
|
||||
final StorePropertyBase<bool> prop;
|
||||
|
||||
/// Exec before make change, after validator.
|
||||
final void Function(bool)? callback;
|
||||
final FutureOr<void> Function(bool)? callback;
|
||||
|
||||
/// If return false, the switch will not change.
|
||||
final bool Function(bool)? validator;
|
||||
@@ -25,9 +27,9 @@ class StoreSwitch extends StatelessWidget {
|
||||
builder: (context, bool value, widget) {
|
||||
return Switch(
|
||||
value: value,
|
||||
onChanged: (value) {
|
||||
onChanged: (value) async {
|
||||
if (validator != null && validator?.call(value) != true) return;
|
||||
callback?.call(value);
|
||||
await callback?.call(value);
|
||||
prop.put(value);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user