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