mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 15:10:49 +08:00
ui: change ui on add settings
This commit is contained in:
@@ -32,8 +32,7 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
child: Text(client.name ?? ""));
|
||||
}
|
||||
return SettingsCard(
|
||||
onTap: () => showDownloadClientDetails(DownloadClient()),
|
||||
child: const Icon(Icons.add));
|
||||
onTap: () => showSelections(), child: const Icon(Icons.add));
|
||||
})),
|
||||
error: (err, trace) => PoNetworkError(err: err),
|
||||
loading: () => const MyProgressIndicator());
|
||||
@@ -42,7 +41,6 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
Future<void> showDownloadClientDetails(DownloadClient client) {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
var _enableAuth = isNotBlank(client.user);
|
||||
String selectImpl = "transmission";
|
||||
|
||||
final body =
|
||||
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
@@ -53,29 +51,12 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
"url": client.url,
|
||||
"user": client.user,
|
||||
"password": client.password,
|
||||
"impl": client.implementation,
|
||||
"remove_completed_downloads": client.removeCompletedDownloads,
|
||||
"remove_failed_downloads": client.removeFailedDownloads,
|
||||
"priority": client.priority.toString(),
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilderDropdown<String>(
|
||||
name: "impl",
|
||||
decoration: const InputDecoration(labelText: "类型"),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectImpl = value!;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: "transmission", child: Text("Transmission")),
|
||||
DropdownMenuItem(
|
||||
value: "qbittorrent", child: Text("qBittorrent")),
|
||||
],
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
FormBuilderTextField(
|
||||
name: "name",
|
||||
decoration: const InputDecoration(labelText: "名称"),
|
||||
@@ -90,7 +71,8 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
),
|
||||
FormBuilderTextField(
|
||||
name: "priority",
|
||||
decoration: const InputDecoration(labelText: "优先级", helperText: "1-50, 1最高优先级,50最低优先级"),
|
||||
decoration: const InputDecoration(
|
||||
labelText: "优先级", helperText: "1-50, 1最高优先级,50最低优先级"),
|
||||
validator: FormBuilderValidators.integer(),
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction),
|
||||
FormBuilderSwitch(
|
||||
@@ -151,7 +133,7 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
return ref.read(dwonloadClientsProvider.notifier).addDownloadClients(
|
||||
DownloadClient(
|
||||
name: values["name"],
|
||||
implementation: values["impl"],
|
||||
implementation: client.implementation,
|
||||
url: values["url"],
|
||||
user: _enableAuth ? values["user"] : null,
|
||||
password: _enableAuth ? values["password"] : null,
|
||||
@@ -163,7 +145,58 @@ class _DownloaderState extends ConsumerState<DownloaderSettings> {
|
||||
}
|
||||
}
|
||||
|
||||
var title = "下载器";
|
||||
if (client.implementation == "transmission") {
|
||||
title = "Transmission";
|
||||
} else if (client.implementation == "qbittorrent") {
|
||||
title = "qBittorrent";
|
||||
}
|
||||
|
||||
return showSettingDialog(
|
||||
context, "下载器", client.id != null, body, onSubmit, onDelete);
|
||||
context, title, client.id != null, body, onSubmit, onDelete);
|
||||
}
|
||||
|
||||
Future<void> showSelections() {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SizedBox(
|
||||
height: 500,
|
||||
width: 500,
|
||||
child: Wrap(
|
||||
children: [
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("Transmission"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showDownloadClientDetails(DownloadClient(
|
||||
implementation: "transmission",
|
||||
name: "Transmission"));
|
||||
},
|
||||
),
|
||||
),
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("qBittorrent"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showDownloadClientDetails(DownloadClient(
|
||||
implementation: "qbittorrent",
|
||||
name: "qBittorrent"));
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:ui/providers/settings.dart';
|
||||
import 'package:ui/settings/dialog.dart';
|
||||
import 'package:ui/widgets/progress_indicator.dart';
|
||||
import 'package:ui/widgets/widgets.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class Importlist extends ConsumerStatefulWidget {
|
||||
const Importlist({super.key});
|
||||
@@ -31,7 +32,7 @@ class _ImportlistState extends ConsumerState<Importlist> {
|
||||
child: Text(indexer.name ?? ""));
|
||||
}
|
||||
return SettingsCard(
|
||||
onTap: () => showImportlistDetails(ImportList()),
|
||||
onTap: () => showSelections(),
|
||||
child: const Icon(Icons.add));
|
||||
}),
|
||||
),
|
||||
@@ -55,24 +56,16 @@ class _ImportlistState extends ConsumerState<Importlist> {
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilderDropdown(
|
||||
name: "type",
|
||||
decoration: const InputDecoration(
|
||||
labelText: "类型",
|
||||
hintText:
|
||||
"Plex Watchlist: https://support.plex.tv/articles/universal-watchlist/"),
|
||||
items: const [
|
||||
DropdownMenuItem(value: "plex", child: Text("Plex Watchlist")),
|
||||
],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectedType = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
_selectedType == "plex"
|
||||
? const Text(
|
||||
"Plex Watchlist: https://support.plex.tv/articles/universal-watchlist/")
|
||||
list.type == "plex"
|
||||
? Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: InkWell(
|
||||
onTap: () => launchUrl(Uri.parse(
|
||||
"https://support.plex.tv/articles/universal-watchlist/")),
|
||||
child: const Text(
|
||||
"https://support.plex.tv/articles/universal-watchlist/"),
|
||||
),
|
||||
)
|
||||
: const Text(""),
|
||||
FormBuilderTextField(
|
||||
name: "name",
|
||||
@@ -141,7 +134,42 @@ class _ImportlistState extends ConsumerState<Importlist> {
|
||||
}
|
||||
}
|
||||
|
||||
var title = "监控列表";
|
||||
if (list.type == "plex") {
|
||||
title = "Plex Watchlist";
|
||||
}
|
||||
|
||||
return showSettingDialog(
|
||||
context, "监控列表", list.id != null, body, onSubmit, onDelete);
|
||||
context, title, list.id != null, body, onSubmit, onDelete);
|
||||
}
|
||||
|
||||
Future<void> showSelections() {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SizedBox(
|
||||
height: 500,
|
||||
width: 500,
|
||||
child: Wrap(
|
||||
children: [
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("Plex Watchlist"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showImportlistDetails(
|
||||
ImportList(type: "plex", name: "PlexWatchlist1"));
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
child: Text(storage.name ?? ""));
|
||||
}
|
||||
return SettingsCard(
|
||||
onTap: () => showStorageDetails(Storage()),
|
||||
onTap: () => showSelections(),
|
||||
child: const Icon(Icons.add));
|
||||
}),
|
||||
),
|
||||
@@ -42,7 +42,6 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
Future<void> showStorageDetails(Storage s) {
|
||||
final _formKey = GlobalKey<FormBuilderState>();
|
||||
|
||||
String selectImpl = s.implementation == null ? "local" : s.implementation!;
|
||||
final widgets =
|
||||
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return FormBuilder(
|
||||
@@ -50,7 +49,6 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
initialValue: {
|
||||
"name": s.name,
|
||||
"impl": s.implementation == null ? "local" : s.implementation!,
|
||||
"user": s.settings != null ? s.settings!["user"] ?? "" : "",
|
||||
"password": s.settings != null ? s.settings!["password"] ?? "" : "",
|
||||
"tv_path": s.tvPath,
|
||||
@@ -65,27 +63,6 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
FormBuilderDropdown<String>(
|
||||
name: "impl",
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
decoration: const InputDecoration(labelText: "类型"),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectImpl = value!;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: "local",
|
||||
child: Text("本地存储"),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: "webdav",
|
||||
child: Text("webdav"),
|
||||
)
|
||||
],
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
FormBuilderTextField(
|
||||
name: "name",
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
@@ -93,7 +70,7 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
decoration: const InputDecoration(labelText: "名称"),
|
||||
validator: FormBuilderValidators.required(),
|
||||
),
|
||||
selectImpl != "local"
|
||||
s.implementation != "local"
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -145,7 +122,7 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
final values = _formKey.currentState!.value;
|
||||
return ref.read(storageSettingProvider.notifier).addStorage(Storage(
|
||||
name: values["name"],
|
||||
implementation: selectImpl,
|
||||
implementation: s.implementation,
|
||||
tvPath: values["tv_path"],
|
||||
moviePath: values["movie_path"],
|
||||
settings: {
|
||||
@@ -167,7 +144,56 @@ class _StorageState extends ConsumerState<StorageSettings> {
|
||||
return ref.read(storageSettingProvider.notifier).deleteStorage(s.id!);
|
||||
}
|
||||
|
||||
var title = "存储";
|
||||
if (s.implementation == "local") {
|
||||
title = "本地存储";
|
||||
} else if (s.implementation == "webdav") {
|
||||
title = "webdav 存储";
|
||||
}
|
||||
|
||||
return showSettingDialog(
|
||||
context, '存储', s.id != null, widgets, onSubmit, onDelete);
|
||||
context, title, s.id != null, widgets, onSubmit, onDelete);
|
||||
}
|
||||
|
||||
Future<void> showSelections() {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SizedBox(
|
||||
height: 500,
|
||||
width: 500,
|
||||
child: Wrap(
|
||||
children: [
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("本地存储"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showStorageDetails(
|
||||
Storage(implementation: "local", name: "本地存储1"));
|
||||
},
|
||||
),
|
||||
),
|
||||
SettingsCard(
|
||||
child: InkWell(
|
||||
child: const Center(
|
||||
child: Text("webdav"),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showStorageDetails(
|
||||
Storage(implementation: "webdav", name: "webdav1"));
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user