mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 19:47:47 +08:00
WIP: init wizard
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
import 'package:ui/settings/downloader.dart';
|
||||||
import 'package:ui/settings/prowlarr.dart';
|
import 'package:ui/settings/prowlarr.dart';
|
||||||
import 'package:ui/widgets/widgets.dart';
|
import 'package:ui/settings/storage.dart';
|
||||||
|
|
||||||
class InitWizard extends ConsumerStatefulWidget {
|
class InitWizard extends ConsumerStatefulWidget {
|
||||||
const InitWizard({super.key});
|
const InitWizard({super.key});
|
||||||
@@ -46,6 +46,7 @@ class _InitWizardState extends ConsumerState<InitWizard> {
|
|||||||
tmdbSetting(),
|
tmdbSetting(),
|
||||||
downloaderSetting(),
|
downloaderSetting(),
|
||||||
indexerSetting(),
|
indexerSetting(),
|
||||||
|
storageSetting(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
@@ -96,95 +97,22 @@ class _InitWizardState extends ConsumerState<InitWizard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget downloaderSetting() {
|
Widget downloaderSetting() {
|
||||||
final _formKey = GlobalKey<FormBuilderState>();
|
|
||||||
var _enableAuth = false;
|
|
||||||
String selectImpl = "transmission";
|
|
||||||
|
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
childrenPadding: EdgeInsets.only(left: 100, right: 20),
|
childrenPadding: EdgeInsets.only(left: 100, right: 20),
|
||||||
initiallyExpanded: true,
|
initiallyExpanded: true,
|
||||||
title: Text("第二步:下载客户端", style: TextStyle(fontWeight: FontWeight.bold)),
|
title: Text("第二步:下载客户端", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
children: [
|
children: [
|
||||||
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
DownloaderSettings(),
|
||||||
return FormBuilder(
|
|
||||||
key: _formKey,
|
|
||||||
initialValue: {
|
|
||||||
"name": "client.name",
|
|
||||||
"url": "client.url",
|
|
||||||
"user": "client.user",
|
|
||||||
"password": "client.password",
|
|
||||||
"impl": selectImpl,
|
|
||||||
},
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
FormBuilderDropdown<String>(
|
|
||||||
name: "impl",
|
|
||||||
decoration: const InputDecoration(labelText: "类型"),
|
|
||||||
items: const [
|
|
||||||
DropdownMenuItem(
|
|
||||||
value: "transmission", child: Text("Transmission")),
|
|
||||||
DropdownMenuItem(
|
|
||||||
value: "qbittorrent", child: Text("qBittorrent")),
|
|
||||||
],
|
|
||||||
validator: FormBuilderValidators.required(),
|
|
||||||
),
|
|
||||||
FormBuilderTextField(
|
|
||||||
name: "name",
|
|
||||||
decoration: const InputDecoration(labelText: "名称"),
|
|
||||||
validator: FormBuilderValidators.required(),
|
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction),
|
|
||||||
FormBuilderTextField(
|
|
||||||
name: "url",
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: "地址", hintText: "http://127.0.0.1:9091"),
|
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
||||||
validator: FormBuilderValidators.required(),
|
|
||||||
),
|
|
||||||
StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
FormBuilderSwitch(
|
|
||||||
name: "auth",
|
|
||||||
title: const Text("需要认证"),
|
|
||||||
initialValue: _enableAuth,
|
|
||||||
onChanged: (v) {
|
|
||||||
setState(() {
|
|
||||||
_enableAuth = v!;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
_enableAuth
|
|
||||||
? Column(
|
|
||||||
children: [
|
|
||||||
FormBuilderTextField(
|
|
||||||
name: "user",
|
|
||||||
decoration:
|
|
||||||
Commons.requiredTextFieldStyle(
|
|
||||||
text: "用户"),
|
|
||||||
validator:
|
|
||||||
FormBuilderValidators.required(),
|
|
||||||
autovalidateMode:
|
|
||||||
AutovalidateMode.onUserInteraction),
|
|
||||||
FormBuilderTextField(
|
|
||||||
name: "password",
|
|
||||||
decoration:
|
|
||||||
Commons.requiredTextFieldStyle(
|
|
||||||
text: "密码"),
|
|
||||||
validator:
|
|
||||||
FormBuilderValidators.required(),
|
|
||||||
obscureText: true,
|
|
||||||
autovalidateMode:
|
|
||||||
AutovalidateMode.onUserInteraction),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Container()
|
|
||||||
],
|
|
||||||
);
|
|
||||||
})
|
|
||||||
],
|
|
||||||
));
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget storageSetting() {
|
||||||
|
return ExpansionTile(
|
||||||
|
childrenPadding: EdgeInsets.only(left: 100, right: 20),
|
||||||
|
title: Text("第四步:存储设置", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
initiallyExpanded: true,
|
||||||
|
children: [StorageSettings()],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user