Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

feat: less alert dialog (#1241)

ErBW_s8dec021a8cf7
diff --git a/lib/bean/widget/collect_button.dart b/lib/bean/widget/collect_button.dart
index c5fe83d5..ff7c151d 100644
--- a/lib/bean/widget/collect_button.dart
+++ b/lib/bean/widget/collect_button.dart
@@ -18,7 +18,6 @@ class CollectButton extends StatefulWidget {
super.key,
required this.bangumiItem,
this.color = Colors.white,
- // this.isExtended = false,
this.onOpen,
this.onClose,
}) {
@@ -90,8 +89,8 @@ class _CollectButtonState extends State<CollectButton> {
consumeOutsideTap: true,
onClose: widget.onClose,
onOpen: widget.onOpen,
- builder:
- (BuildContext context, MenuController controller, Widget? child) {
+ crossAxisUnconstrained: false,
+ builder: (_, MenuController controller, __) {
if (widget.isExtended) {
return FilledButton.icon(
onPressed: () {
@@ -129,23 +128,31 @@ class _CollectButtonState extends State<CollectButton> {
setState(() {});
}
},
- child: Padding(
- padding: const EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(getIconByInt(index),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(
+ getIconByInt(index),
color: index == collectType
? Theme.of(context).colorScheme.primary
- : null),
- Text(
- ' ${getTypeStringByInt(index)}',
- style: TextStyle(
+ : null,
+ ),
+ SizedBox(width: 4),
+ Text(
+ ' ${getTypeStringByInt(index)}',
+ style: TextStyle(
color: index == collectType
? Theme.of(context).colorScheme.primary
- : null),
- ),
- ],
+ : null,
+ ),
+ ),
+ ],
+ ),
),
),
),
diff --git a/lib/pages/about/about_page.dart b/lib/pages/about/about_page.dart
index a37656e7..b5d1f930 100644
--- a/lib/pages/about/about_page.dart
+++ b/lib/pages/about/about_page.dart
@@ -23,7 +23,6 @@ class AboutPage extends StatefulWidget {
class _AboutPageState extends State<AboutPage> {
final exitBehaviorTitles = <String>['退出 Kazumi', '最小化至托盘', '每次都询问'];
-
late dynamic defaultDanmakuArea;
late dynamic defaultThemeMode;
late dynamic defaultThemeColor;
@@ -33,6 +32,7 @@ class _AboutPageState extends State<AboutPage> {
late bool autoUpdate;
double _cacheSizeMB = -1;
final MyController myController = Modular.get<MyController>();
+ final MenuController menuController = MenuController();
@override
void initState() {
@@ -138,141 +138,152 @@ class _AboutPageState extends State<AboutPage> {
child: Scaffold(
appBar: const SysAppBar(title: Text('关于')),
// backgroundColor: Colors.transparent,
- body: Center(
- child: SizedBox(
- width: (MediaQuery.of(context).size.width > 1000) ? 1000 : null,
- child: SettingsList(
- sections: [
- SettingsSection(
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- Modular.to.pushNamed('/settings/about/license');
- },
- title: const Text('开源许可证'),
- description: const Text('查看所有开源许可证'),
- ),
- ],
+ body: SettingsList(
+ maxWidth: 1000,
+ sections: [
+ SettingsSection(
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ Modular.to.pushNamed('/settings/about/license');
+ },
+ title: const Text('开源许可证'),
+ description: const Text('查看所有开源许可证'),
),
- SettingsSection(
- title: const Text('外部链接'),
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- launchUrl(Uri.parse(Api.sourceUrl),
- mode: LaunchMode.externalApplication);
- },
- title: const Text('项目主页'),
- value: const Text('Github'),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- launchUrl(Uri.parse(Api.iconUrl),
- mode: LaunchMode.externalApplication);
- },
- title: const Text('图标创作'),
- value: const Text('Pixiv'),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- launchUrl(Uri.parse(Api.bangumiIndex),
- mode: LaunchMode.externalApplication);
- },
- title: const Text('番剧索引'),
- value: const Text('Bangumi'),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- launchUrl(Uri.parse(Api.dandanIndex),
- mode: LaunchMode.externalApplication);
- },
- title: const Text('弹幕来源'),
- description: Text('ID: ${mortis['id']}'),
- value: const Text('DanDanPlay'),
- ),
- ],
+ ],
+ ),
+ SettingsSection(
+ title: const Text('外部链接'),
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ launchUrl(Uri.parse(Api.sourceUrl),
+ mode: LaunchMode.externalApplication);
+ },
+ title: const Text('项目主页'),
+ value: const Text('Github'),
),
- if (Utils.isDesktop()) // 之后如果有非桌面平台的新选项可以移除
- SettingsSection(
- title: const Text('默认行为'),
- tiles: [
- // if (Utils.isDesktop())
- SettingsTile.navigation(
- title: const Text('关闭时'),
- value: Text(exitBehaviorTitles[exitBehavior]),
- onPressed: (_) {
- KazumiDialog.show(builder: (context) {
- return SimpleDialog(
- clipBehavior: Clip.antiAlias,
- title: const Text('关闭时'),
- children: [
- for (int i = 0; i < 3; i++)
- RadioListTile(
- value: i,
- groupValue: exitBehavior,
- onChanged: (int? value) {
- exitBehavior = value ?? 2;
- setting.put(
- SettingBoxKey.exitBehavior, value);
- KazumiDialog.dismiss();
- setState(() {});
- },
- title: Text(exitBehaviorTitles[i]),
- ),
- ],
- );
- });
- },
- ),
- ],
- ),
- SettingsSection(
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- Modular.to.pushNamed('/settings/about/logs');
- },
- title: const Text('错误日志'),
- ),
- ],
+ SettingsTile.navigation(
+ onPressed: (_) {
+ launchUrl(Uri.parse(Api.iconUrl),
+ mode: LaunchMode.externalApplication);
+ },
+ title: const Text('图标创作'),
+ value: const Text('Pixiv'),
),
- SettingsSection(
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- _showCacheDialog();
- },
- title: const Text('清除缓存'),
- value: _cacheSizeMB == -1
- ? const Text('统计中...')
- : Text('${_cacheSizeMB.toStringAsFixed(2)}MB'),
- ),
- ],
+ SettingsTile.navigation(
+ onPressed: (_) {
+ launchUrl(Uri.parse(Api.bangumiIndex),
+ mode: LaunchMode.externalApplication);
+ },
+ title: const Text('番剧索引'),
+ value: const Text('Bangumi'),
),
- SettingsSection(
- title: const Text('应用更新'),
- tiles: [
- SettingsTile.switchTile(
- onToggle: (value) async {
- autoUpdate = value ?? !autoUpdate;
- await setting.put(SettingBoxKey.autoUpdate, autoUpdate);
- setState(() {});
- },
- title: const Text('自动更新'),
- initialValue: autoUpdate,
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- myController.checkUpdate();
+ SettingsTile.navigation(
+ onPressed: (_) {
+ launchUrl(Uri.parse(Api.dandanIndex),
+ mode: LaunchMode.externalApplication);
+ },
+ title: const Text('弹幕来源'),
+ description: Text('ID: ${mortis['id']}'),
+ value: const Text('DanDanPlay'),
+ ),
+ ],
+ ),
+ if (Utils.isDesktop()) // 之后如果有非桌面平台的新选项可以移除
+ SettingsSection(
+ title: const Text('默认行为'),
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ if (menuController.isOpen) {
+ menuController.close();
+ } else {
+ menuController.open();
+ }
+ },
+ title: const Text('关闭时'),
+ value: MenuAnchor(
+ consumeOutsideTap: true,
+ controller: menuController,
+ builder: (_, __, ___) {
+ return Text(exitBehaviorTitles[exitBehavior]);
},
- title: const Text('检查更新'),
- value: const Text('当前版本 ${Api.version}'),
+ menuChildren: [
+ for (int i = 0; i < 3; i++)
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () {
+ exitBehavior = i;
+ setting.put(SettingBoxKey.exitBehavior, i);
+ setState(() {});
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ exitBehaviorTitles[i],
+ style: TextStyle(
+ color: i == exitBehavior
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
),
- ],
+ ),
+ ],
+ ),
+ SettingsSection(
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ Modular.to.pushNamed('/settings/about/logs');
+ },
+ title: const Text('错误日志'),
),
],
),
- ),
+ SettingsSection(
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ _showCacheDialog();
+ },
+ title: const Text('清除缓存'),
+ value: _cacheSizeMB == -1
+ ? const Text('统计中...')
+ : Text('${_cacheSizeMB.toStringAsFixed(2)}MB'),
+ ),
+ ],
+ ),
+ SettingsSection(
+ title: const Text('应用更新'),
+ tiles: [
+ SettingsTile.switchTile(
+ onToggle: (value) async {
+ autoUpdate = value ?? !autoUpdate;
+ await setting.put(SettingBoxKey.autoUpdate, autoUpdate);
+ setState(() {});
+ },
+ title: const Text('自动更新'),
+ initialValue: autoUpdate,
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ myController.checkUpdate();
+ },
+ title: const Text('检查更新'),
+ value: const Text('当前版本 ${Api.version}'),
+ ),
+ ],
+ ),
+ ],
),
),
);
diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dart
index 50d6683a..039a4683 100644
--- a/lib/pages/player/player_item_panel.dart
+++ b/lib/pages/player/player_item_panel.dart
@@ -649,18 +649,26 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
onPressed: () {
widget.showDanmakuSwitch();
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("弹幕切换"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("弹幕切换"),
+ ),
),
),
MenuItemButton(
onPressed: () {
widget.showVideoInfo();
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("视频详情"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("视频详情"),
+ ),
),
),
MenuItemButton(
@@ -678,75 +686,106 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
}
});
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("远程投屏"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("远程投屏"),
+ ),
),
),
MenuItemButton(
onPressed: () {
playerController.lanunchExternalPlayer();
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("外部播放"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("外部播放"),
+ ),
),
),
SubmenuButton(
- menuChildren: [
- MenuItemButton(
- child: Padding(
- padding:
- EdgeInsets.fromLTRB(0, 10, 10, 10),
+ menuChildren: [
+ MenuItemButton(
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text(
"当前房间: ${playerController.syncplayRoom == '' ? '未加入' : playerController.syncplayRoom}"),
),
),
- MenuItemButton(
- child: Padding(
- padding:
- EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text(
"网络延时: ${playerController.syncplayClientRtt}ms"),
),
),
- MenuItemButton(
- onPressed: () {
- widget.showSyncPlayRoomCreateDialog();
- },
- child: const Padding(
- padding:
- EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ onPressed: () {
+ widget.showSyncPlayRoomCreateDialog();
+ },
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text("加入房间"),
),
),
- MenuItemButton(
- onPressed: () {
- widget
- .showSyncPlayEndPointSwitchDialog();
- },
- child: const Padding(
- padding:
- EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ onPressed: () {
+ widget.showSyncPlayEndPointSwitchDialog();
+ },
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text("切换服务器"),
),
),
- MenuItemButton(
- onPressed: () async {
- await playerController
- .exitSyncPlayRoom();
- },
- child: const Padding(
- padding:
- EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ onPressed: () async {
+ await playerController.exitSyncPlayRoom();
+ },
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text("断开连接"),
),
),
- ],
- child: const Padding(
- padding:
- EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("一起看"))),
+ ),
+ ],
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("一起看"),
+ ),
+ ),
+ ),
],
),
],
@@ -927,10 +966,6 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
widget.keyboardFocus
.requestFocus();
showModalBottomSheet(
- backgroundColor: Theme.of(
- context)
- .colorScheme
- .surface,
isScrollControlled: true,
constraints: BoxConstraints(
maxHeight:
@@ -1068,23 +1103,27 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
(int index) => MenuItemButton(
onPressed: () =>
playerController.setShader(index + 1),
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- 0, 10, 10, 10),
- child: Text(
- index + 1 == 1
- ? '关闭'
- : index + 1 == 2
- ? '效率档'
- : '质量档',
- style: TextStyle(
- color: playerController
- .superResolutionType ==
- index + 1
- ? Theme.of(context)
- .colorScheme
- .primary
- : null,
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ index + 1 == 1
+ ? '关闭'
+ : index + 1 == 2
+ ? '效率档'
+ : '质量档',
+ style: TextStyle(
+ color: playerController
+ .superResolutionType ==
+ index + 1
+ ? Theme.of(context)
+ .colorScheme
+ .primary
+ : null,
+ ),
),
),
),
@@ -1129,19 +1168,24 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
onPressed: () async {
await widget.setPlaybackSpeed(i);
},
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- 0, 10, 10, 10),
- child: Text(
- '${i}x',
- style: TextStyle(
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ '${i}x',
+ style: TextStyle(
color: i ==
playerController
.playerSpeed
? Theme.of(context)
.colorScheme
.primary
- : null),
+ : null,
+ ),
+ ),
),
),
),
@@ -1182,19 +1226,23 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {
MenuItemButton(
onPressed: () => playerController
.aspectRatioType = entry.key,
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- 0, 10, 10, 10),
- child: Text(
- entry.value,
- style: TextStyle(
- color: entry.key ==
- playerController
- .aspectRatioType
- ? Theme.of(context)
- .colorScheme
- .primary
- : null,
+ child: Container(
+ height: 48,
+ constraints:
+ BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ entry.value,
+ style: TextStyle(
+ color: entry.key ==
+ playerController
+ .aspectRatioType
+ ? Theme.of(context)
+ .colorScheme
+ .primary
+ : null,
+ ),
),
),
),
diff --git a/lib/pages/player/smallest_player_item_panel.dart b/lib/pages/player/smallest_player_item_panel.dart
index 4ca822c9..92452932 100644
--- a/lib/pages/player/smallest_player_item_panel.dart
+++ b/lib/pages/player/smallest_player_item_panel.dart
@@ -441,29 +441,37 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {
(int index) => MenuItemButton(
onPressed: () => playerController
.aspectRatioType = index + 1,
- child: Padding(
- padding:
- const EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text(
- index + 1 == 1
- ? '自动'
- : index + 1 == 2
- ? '裁切填充'
- : '拉伸填充',
- style: TextStyle(
- color: index + 1 ==
- playerController.aspectRatioType
- ? Theme.of(context)
- .colorScheme
- .primary
- : null),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ index + 1 == 1
+ ? '自动'
+ : index + 1 == 2
+ ? '裁切填充'
+ : '拉伸填充',
+ style: TextStyle(
+ color: index + 1 ==
+ playerController
+ .aspectRatioType
+ ? Theme.of(context)
+ .colorScheme
+ .primary
+ : null),
+ ),
),
),
),
),
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("视频比例"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("视频比例"),
+ ),
),
),
SubmenuButton(
@@ -474,26 +482,33 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {
onPressed: () async {
await widget.setPlaybackSpeed(i);
},
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- 0, 10, 10, 10),
- child: Text(
- '${i}x',
- style: TextStyle(
- color:
- i == playerController.playerSpeed
- ? Theme.of(context)
- .colorScheme
- .primary
- : null),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ '${i}x',
+ style: TextStyle(
+ color: i ==
+ playerController.playerSpeed
+ ? Theme.of(context)
+ .colorScheme
+ .primary
+ : null),
+ ),
),
),
),
],
],
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("倍速"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("倍速"),
+ ),
),
),
SubmenuButton(
@@ -502,94 +517,129 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {
(int index) => MenuItemButton(
onPressed: () =>
playerController.setShader(index + 1),
- child: Padding(
- padding:
- const EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text(
- index + 1 == 1
- ? '关闭'
- : index + 1 == 2
- ? '效率档'
- : '质量档',
- style: TextStyle(
- color: playerController
- .superResolutionType ==
- index + 1
- ? Theme.of(context)
- .colorScheme
- .primary
- : null,
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ index + 1 == 1
+ ? '关闭'
+ : index + 1 == 2
+ ? '效率档'
+ : '质量档',
+ style: TextStyle(
+ color: playerController
+ .superResolutionType ==
+ index + 1
+ ? Theme.of(context)
+ .colorScheme
+ .primary
+ : null,
+ ),
),
),
),
),
),
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("超分辨率"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("超分辨率"),
+ ),
),
),
SubmenuButton(
- menuChildren: [
- MenuItemButton(
- child: Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
+ menuChildren: [
+ MenuItemButton(
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text(
"当前房间: ${playerController.syncplayRoom == '' ? '未加入' : playerController.syncplayRoom}"),
),
),
- MenuItemButton(
- child: Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text(
"网络延时: ${playerController.syncplayClientRtt}ms"),
),
),
- MenuItemButton(
- onPressed: () {
- widget.showSyncPlayRoomCreateDialog();
- },
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ onPressed: () {
+ widget.showSyncPlayRoomCreateDialog();
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text("加入房间"),
),
),
- MenuItemButton(
- onPressed: () {
- widget.showSyncPlayEndPointSwitchDialog();
- },
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ onPressed: () {
+ widget.showSyncPlayEndPointSwitchDialog();
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text("切换服务器"),
),
),
- MenuItemButton(
- onPressed: () async {
- await playerController.exitSyncPlayRoom();
- },
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
+ ),
+ MenuItemButton(
+ onPressed: () async {
+ await playerController.exitSyncPlayRoom();
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
child: Text("断开连接"),
),
),
- ],
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("一起看"))),
+ ),
+ ],
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("一起看"),
+ ),
+ ),
+ ),
MenuItemButton(
onPressed: () {
widget.showDanmakuSwitch();
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("弹幕切换"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("弹幕切换"),
+ ),
),
),
MenuItemButton(
onPressed: () {
showModalBottomSheet(
- backgroundColor:
- Theme.of(context).colorScheme.surface,
isScrollControlled: true,
constraints: BoxConstraints(
maxHeight:
@@ -611,18 +661,26 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {
},
);
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("弹幕设置"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("弹幕设置"),
+ ),
),
),
MenuItemButton(
onPressed: () {
widget.showVideoInfo();
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("视频详情"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("视频详情"),
+ ),
),
),
MenuItemButton(
@@ -638,18 +696,26 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {
}
});
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("远程投屏"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("远程投屏"),
+ ),
),
),
MenuItemButton(
onPressed: () {
playerController.lanunchExternalPlayer();
},
- child: const Padding(
- padding: EdgeInsets.fromLTRB(0, 10, 10, 10),
- child: Text("外部播放"),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text("外部播放"),
+ ),
),
),
],
diff --git a/lib/pages/plugin_editor/plugin_view_page.dart b/lib/pages/plugin_editor/plugin_view_page.dart
index 9485409a..6c62bbf0 100644
--- a/lib/pages/plugin_editor/plugin_view_page.dart
+++ b/lib/pages/plugin_editor/plugin_view_page.dart
@@ -204,17 +204,19 @@ class _PluginViewPageState extends State<PluginViewPage> {
),
] else ...[
IconButton(
- onPressed: () {
- _handleUpdate();
- },
- tooltip: '更新全部',
- icon: const Icon(Icons.update)),
+ onPressed: () {
+ _handleUpdate();
+ },
+ tooltip: '更新全部',
+ icon: const Icon(Icons.update),
+ ),
IconButton(
- onPressed: () {
- _handleAdd();
- },
- tooltip: '添加规则',
- icon: const Icon(Icons.add))
+ onPressed: () {
+ _handleAdd();
+ },
+ tooltip: '添加规则',
+ icon: const Icon(Icons.add),
+ )
],
],
),
@@ -339,15 +341,6 @@ class _PluginViewPageState extends State<PluginViewPage> {
],
],
),
- if (pluginsController.installTimeTracker
- .getInstallTime(plugin.name) >
- 0) ...[
- Text(
- '安装时间: ${DateTime.fromMillisecondsSinceEpoch(pluginsController.installTimeTracker.getInstallTime(plugin.name)).toString().split('.')[0]}',
- style:
- const TextStyle(color: Colors.grey),
- ),
- ],
],
),
));
@@ -387,81 +380,155 @@ class _PluginViewPageState extends State<PluginViewPage> {
Widget popupMenuButton(int index) {
final plugin = pluginsController.pluginList[index];
- return PopupMenuButton<String>(
- onSelected: (String result) async {
- if (result == 'Update') {
- var state = pluginsController.pluginUpdateStatus(plugin);
- if (state == "nonexistent") {
- KazumiDialog.showToast(message: '规则仓库中没有当前规则');
- } else if (state == "latest") {
- KazumiDialog.showToast(message: '规则已是最新');
- } else if (state == "updatable") {
- KazumiDialog.showLoading(msg: '更新中');
- int res = await pluginsController.tryUpdatePlugin(plugin);
- KazumiDialog.dismiss();
- if (res == 0) {
- KazumiDialog.showToast(message: '更新成功');
- } else if (res == 1) {
- KazumiDialog.showToast(message: 'kazumi版本过低, 此规则不兼容当前版本');
- } else if (res == 2) {
- KazumiDialog.showToast(message: '更新规则失败');
+ return MenuAnchor(
+ consumeOutsideTap: true,
+ builder:
+ (BuildContext context, MenuController controller, Widget? child) {
+ return IconButton(
+ onPressed: () {
+ if (controller.isOpen) {
+ controller.close();
+ } else {
+ controller.open();
}
- }
- } else if (result == 'Delete') {
- setState(() {
- pluginsController.removePlugin(plugin);
- });
- } else if (result == 'Edit') {
- Modular.to.pushNamed('/settings/plugin/editor', arguments: plugin);
- } else if (result == 'Share') {
- KazumiDialog.show(builder: (context) {
- return AlertDialog(
- title: const Text('规则链接'),
- content: SelectableText(
- Utils.jsonToKazumiBase64(
- json.encode(pluginsController.pluginList[index].toJson())),
- style: const TextStyle(fontWeight: FontWeight.bold),
- textAlign: TextAlign.center,
- ),
- actions: [
- TextButton(
- onPressed: () => KazumiDialog.dismiss(),
- child: Text(
- '取消',
- style:
- TextStyle(color: Theme.of(context).colorScheme.outline),
- ),
- ),
- TextButton(
- onPressed: () {
- Clipboard.setData(ClipboardData(
- text: Utils.jsonToKazumiBase64(json.encode(
- pluginsController.pluginList[index].toJson()))));
- KazumiDialog.dismiss();
- },
- child: const Text('复制到剪贴板'),
- ),
- ],
- );
- });
- }
+ },
+ icon: const Icon(
+ Icons.more_vert,
+ color: Colors.white,
+ ),
+ );
},
- itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
- const PopupMenuItem<String>(
- value: 'Update',
- child: Text('更新'),
+ menuChildren: [
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () async {
+ var state = pluginsController.pluginUpdateStatus(plugin);
+ if (state == "nonexistent") {
+ KazumiDialog.showToast(message: '规则仓库中没有当前规则');
+ } else if (state == "latest") {
+ KazumiDialog.showToast(message: '规则已是最新');
+ } else if (state == "updatable") {
+ KazumiDialog.showLoading(msg: '更新中');
+ int res = await pluginsController.tryUpdatePlugin(plugin);
+ KazumiDialog.dismiss();
+ if (res == 0) {
+ KazumiDialog.showToast(message: '更新成功');
+ } else if (res == 1) {
+ KazumiDialog.showToast(message: 'kazumi版本过低, 此规则不兼容当前版本');
+ } else if (res == 2) {
+ KazumiDialog.showToast(message: '更新规则失败');
+ }
+ }
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(Icons.update_rounded),
+ SizedBox(width: 8),
+ Text('更新'),
+ ],
+ ),
+ ),
+ ),
),
- const PopupMenuItem<String>(
- value: 'Edit',
- child: Text('编辑'),
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () {
+ Modular.to.pushNamed('/settings/plugin/editor', arguments: plugin);
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(Icons.edit),
+ SizedBox(width: 8),
+ Text('编辑'),
+ ],
+ ),
+ ),
+ ),
),
- const PopupMenuItem<String>(
- value: 'Share',
- child: Text('分享'),
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () {
+ KazumiDialog.show(builder: (context) {
+ return AlertDialog(
+ title: const Text('规则链接'),
+ content: SelectableText(
+ Utils.jsonToKazumiBase64(json
+ .encode(pluginsController.pluginList[index].toJson())),
+ style: const TextStyle(fontWeight: FontWeight.bold),
+ textAlign: TextAlign.center,
+ ),
+ actions: [
+ TextButton(
+ onPressed: () => KazumiDialog.dismiss(),
+ child: Text(
+ '取消',
+ style: TextStyle(
+ color: Theme.of(context).colorScheme.outline),
+ ),
+ ),
+ TextButton(
+ onPressed: () {
+ Clipboard.setData(ClipboardData(
+ text: Utils.jsonToKazumiBase64(
+ json.encode(
+ pluginsController.pluginList[index].toJson(),
+ ),
+ ),
+ ));
+ KazumiDialog.dismiss();
+ },
+ child: const Text('复制到剪贴板'),
+ ),
+ ],
+ );
+ });
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(Icons.share),
+ SizedBox(width: 8),
+ Text('分享'),
+ ],
+ ),
+ ),
+ ),
),
- const PopupMenuItem<String>(
- value: 'Delete',
- child: Text('删除'),
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () async {
+ setState(() {
+ pluginsController.removePlugin(plugin);
+ });
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(Icons.delete),
+ SizedBox(width: 8),
+ Text('删除'),
+ ],
+ ),
+ ),
+ ),
),
],
);
diff --git a/lib/pages/settings/player_settings.dart b/lib/pages/settings/player_settings.dart
index a5b919a9..c5108731 100644
--- a/lib/pages/settings/player_settings.dart
+++ b/lib/pages/settings/player_settings.dart
@@ -27,6 +27,7 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {
late bool showPlayerError;
late bool privateMode;
late bool playerDebugMode;
+ final MenuController menuController = MenuController();
@override
void initState() {
@@ -71,7 +72,6 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {
@override
Widget build(BuildContext context) {
- WidgetsBinding.instance.addPostFrameCallback((_) {});
return PopScope(
canPop: true,
onPopInvokedWithResult: (bool didPop, Object? result) {
@@ -94,7 +94,7 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {
initialValue: hAenable,
),
SettingsTile.navigation(
- onPressed: (value) async {
+ onPressed: (_) async {
await Modular.to.pushNamed('/settings/player/decoder');
},
title: const Text('硬件解码器'),
@@ -196,64 +196,45 @@ class _PlayerSettingsPageState extends State<PlayerSettingsPage> {
),
SettingsTile.navigation(
onPressed: (_) async {
- KazumiDialog.show(builder: (context) {
- return AlertDialog(
- title: const Text('默认视频比例'),
- content: StatefulBuilder(
- builder:
- (BuildContext context, StateSetter setState) {
- return Wrap(
- spacing: 8,
- runSpacing: Utils.isDesktop() ? 8 : 0,
- children: [
- for (final entry
- in aspectRatioTypeMap.entries) ...<Widget>[
- if (entry.key ==
- defaultAspectRatioType) ...<Widget>[
- FilledButton(
- onPressed: () async {
- updateDefaultAspectRatioType(entry.key);
- KazumiDialog.dismiss();
- },
- child: Text(entry.value),
- ),
- ] else ...[
- FilledButton.tonal(
- onPressed: () async {
- updateDefaultAspectRatioType(entry.key);
- KazumiDialog.dismiss();
- },
- child: Text(entry.value),
- ),
- ]
- ]
- ],
- );
- },
- ),
- actions: <Widget>[
- TextButton(
- onPressed: () => KazumiDialog.dismiss(),
- child: Text(
- '取消',
- style: TextStyle(
- color: Theme.of(context).colorScheme.outline),
- ),
- ),
- TextButton(
- onPressed: () async {
- updateDefaultAspectRatioType(1); // 默认恢复自动
- KazumiDialog.dismiss();
- },
- child: const Text('默认设置'),
- ),
- ],
- );
- });
+ if (menuController.isOpen) {
+ menuController.close();
+ } else {
+ menuController.open();
+ }
},
title: const Text('默认视频比例'),
- value:
- Text(aspectRatioTypeMap[defaultAspectRatioType] ?? '自动'),
+ value: MenuAnchor(
+ consumeOutsideTap: true,
+ controller: menuController,
+ builder: (_, __, ___) {
+ return Text(
+ aspectRatioTypeMap[defaultAspectRatioType] ?? '自动',
+ );
+ },
+ menuChildren: [
+ for (final entry in aspectRatioTypeMap.entries)
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () =>
+ updateDefaultAspectRatioType(entry.key),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ entry.value,
+ style: TextStyle(
+ color: entry.key == defaultAspectRatioType
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
),
],
),
diff --git a/lib/pages/settings/theme_settings_page.dart b/lib/pages/settings/theme_settings_page.dart
index 442890b8..17c01bc6 100644
--- a/lib/pages/settings/theme_settings_page.dart
+++ b/lib/pages/settings/theme_settings_page.dart
@@ -31,6 +31,7 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {
late bool showWindowButton;
final PopularController popularController = Modular.get<PopularController>();
late final ThemeProvider themeProvider;
+ final MenuController menuController = MenuController();
@override
void initState() {
@@ -129,7 +130,6 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {
@override
Widget build(BuildContext context) {
- WidgetsBinding.instance.addPostFrameCallback((_) {});
return PopScope(
canPop: true,
onPopInvokedWithResult: (bool didPop, Object? result) {
@@ -145,67 +145,115 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {
tiles: [
SettingsTile.navigation(
onPressed: (_) {
- KazumiDialog.show(builder: (context) {
- return AlertDialog(
- title: const Text('深色模式'),
- content: StatefulBuilder(
- builder:
- (BuildContext context, StateSetter setState) {
- return Wrap(
- spacing: 8,
- runSpacing: Utils.isDesktop() ? 8 : 0,
+ if (menuController.isOpen) {
+ menuController.close();
+ } else {
+ menuController.open();
+ }
+ },
+ title: const Text('深色模式'),
+ value: MenuAnchor(
+ consumeOutsideTap: true,
+ controller: menuController,
+ builder: (_, __, ___) {
+ return Text(
+ defaultThemeMode == 'light'
+ ? '浅色'
+ : (defaultThemeMode == 'dark' ? '深色' : '跟随系统'),
+ );
+ },
+ menuChildren: [
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () => updateTheme('system'),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
children: [
- defaultThemeMode == 'system'
- ? FilledButton(
- onPressed: () {
- updateTheme('system');
- KazumiDialog.dismiss();
- },
- child: const Text("跟随系统"))
- : FilledButton.tonal(
- onPressed: () {
- updateTheme('system');
- KazumiDialog.dismiss();
- },
- child: const Text("跟随系统")),
- defaultThemeMode == 'light'
- ? FilledButton(
- onPressed: () {
- updateTheme('light');
- KazumiDialog.dismiss();
- },
- child: const Text("浅色"))
- : FilledButton.tonal(
- onPressed: () {
- updateTheme('light');
- KazumiDialog.dismiss();
- },
- child: const Text("浅色")),
- defaultThemeMode == 'dark'
- ? FilledButton(
- onPressed: () {
- updateTheme('dark');
- KazumiDialog.dismiss();
- },
- child: const Text("深色"))
- : FilledButton.tonal(
- onPressed: () {
- updateTheme('dark');
- KazumiDialog.dismiss();
- },
- child: const Text("深色")),
+ Icon(
+ Icons.brightness_auto_rounded,
+ color: defaultThemeMode == 'system'
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ SizedBox(width: 8),
+ Text(
+ '跟随系统',
+ style: TextStyle(
+ color: defaultThemeMode == 'system'
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ ),
],
- );
- },
+ ),
+ ),
),
- );
- });
- },
- title: const Text('深色模式'),
- value: Text(
- defaultThemeMode == 'light'
- ? '浅色'
- : (defaultThemeMode == 'dark' ? '深色' : '跟随系统'),
+ ),
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () => updateTheme('light'),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(
+ Icons.light_mode_rounded,
+ color: defaultThemeMode == 'light'
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ SizedBox(width: 8),
+ Text(
+ '浅色',
+ style: TextStyle(
+ color: defaultThemeMode == 'light'
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ MenuItemButton(
+ requestFocusOnHover: false,
+ onPressed: () => updateTheme('dark'),
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ Icon(
+ Icons.dark_mode_rounded,
+ color: defaultThemeMode == 'dark'
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ SizedBox(width: 8),
+ Text(
+ '深色',
+ style: TextStyle(
+ color: defaultThemeMode == 'dark'
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
),
),
SettingsTile.navigation(
diff --git a/lib/pages/video/video_page.dart b/lib/pages/video/video_page.dart
index dc89fc3b..40faa6a9 100644
--- a/lib/pages/video/video_page.dart
+++ b/lib/pages/video/video_page.dart
@@ -657,56 +657,52 @@ class _VideoPageState extends State<VideoPage>
),
),
const SizedBox(width: 10),
- SizedBox(
- height: 34,
- child: TextButton(
- style: ButtonStyle(
- padding: WidgetStateProperty.all(EdgeInsets.zero),
- ),
- onPressed: () {
- KazumiDialog.show(builder: (context) {
- return AlertDialog(
- title: const Text('播放列表'),
- content: StatefulBuilder(builder:
- (BuildContext context, StateSetter innerSetState) {
- return Wrap(
- spacing: 8,
- runSpacing: Utils.isDesktop() ? 8 : 0,
- children: [
- for (int i = 1;
- i <= videoPageController.roadList.length;
- i++) ...<Widget>[
- if (i == currentRoad + 1) ...<Widget>[
- FilledButton(
- onPressed: () {
- KazumiDialog.dismiss();
- setState(() {
- currentRoad = i - 1;
- });
- },
- child: Text('播放列表$i'),
- ),
- ] else ...[
- FilledButton.tonal(
- onPressed: () {
- KazumiDialog.dismiss();
- setState(() {
- currentRoad = i - 1;
- });
- },
- child: Text('播放列表$i'),
- ),
- ]
- ]
- ],
- );
- }),
- );
- });
- },
- child: Text(
- '播放列表${currentRoad + 1} ',
- style: const TextStyle(fontSize: 13),
+ MenuAnchor(
+ consumeOutsideTap: true,
+ builder: (_, MenuController controller, __) {
+ return SizedBox(
+ height: 34,
+ child: TextButton(
+ style: ButtonStyle(
+ padding: WidgetStateProperty.all(EdgeInsets.zero),
+ ),
+ onPressed: () {
+ if (controller.isOpen) {
+ controller.close();
+ } else {
+ controller.open();
+ }
+ },
+ child: Text(
+ '播放列表${currentRoad + 1} ',
+ style: const TextStyle(fontSize: 13),
+ ),
+ ),
+ );
+ },
+ menuChildren: List<MenuItemButton>.generate(
+ videoPageController.roadList.length,
+ (int i) => MenuItemButton(
+ onPressed: () {
+ setState(() {
+ currentRoad = i;
+ });
+ },
+ child: Container(
+ height: 48,
+ constraints: BoxConstraints(minWidth: 112),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ '播放列表${i + 1}',
+ style: TextStyle(
+ color: i == currentRoad
+ ? Theme.of(context).colorScheme.primary
+ : null,
+ ),
+ ),
+ ),
+ ),
),
),
),
diff --git a/lib/pages/webdav_editor/webdav_setting.dart b/lib/pages/webdav_editor/webdav_setting.dart
index 1d0e3235..2cdbe055 100644
--- a/lib/pages/webdav_editor/webdav_setting.dart
+++ b/lib/pages/webdav_editor/webdav_setting.dart
@@ -113,108 +113,100 @@ class _PlayerSettingsPageState extends State<WebDavSettingsPage> {
},
child: Scaffold(
appBar: const SysAppBar(title: Text('同步设置')),
- body: Center(
- child: SizedBox(
- width: (MediaQuery.of(context).size.width > 1000) ? 1000 : null,
- child: SettingsList(
- sections: [
- SettingsSection(
- title: const Text('Github'),
- tiles: [
- SettingsTile.switchTile(
- onToggle: (value) async {
- enableGitProxy = value ?? !enableGitProxy;
- await setting.put(
- SettingBoxKey.enableGitProxy, enableGitProxy);
- setState(() {});
- },
- title: const Text('Github镜像'),
- description: const Text('使用镜像访问规则托管仓库'),
- initialValue: enableGitProxy,
- ),
- ],
+ body: SettingsList(
+ maxWidth: 1000,
+ sections: [
+ SettingsSection(
+ title: const Text('Github'),
+ tiles: [
+ SettingsTile.switchTile(
+ onToggle: (value) async {
+ enableGitProxy = value ?? !enableGitProxy;
+ await setting.put(
+ SettingBoxKey.enableGitProxy, enableGitProxy);
+ setState(() {});
+ },
+ title: const Text('Github镜像'),
+ description: const Text('使用镜像访问规则托管仓库'),
+ initialValue: enableGitProxy,
),
- SettingsSection(
- title: const Text('WEBDAV'),
- tiles: [
- SettingsTile.switchTile(
- onToggle: (value) async {
- webDavEnable = value ?? !webDavEnable;
- if (!WebDav().initialized && webDavEnable) {
- try{
- await WebDav().init();
- } catch (e) {
- webDavEnable = false;
- KazumiDialog.showToast(message: 'WEBDAV初始化失败 $e');
- }
- }
- if (!webDavEnable) {
- webDavEnableHistory = false;
- await setting.put(
- SettingBoxKey.webDavEnableHistory, false);
- }
- await setting.put(
- SettingBoxKey.webDavEnable, webDavEnable);
- if (mounted) {
- setState(() {});
- }
- },
- title: const Text('WEBDAV同步'),
- initialValue: webDavEnable,
- ),
- SettingsTile.switchTile(
- onToggle: (value) async {
- if (!webDavEnable) {
- KazumiDialog.showToast(message: '请先开启WEBDAV同步');
- return;
- }
- webDavEnableHistory = value ?? !webDavEnableHistory;
- await setting.put(SettingBoxKey.webDavEnableHistory,
- webDavEnableHistory);
- setState(() {});
- },
- title: const Text('观看记录同步'),
- description: const Text('允许自动同步观看记录'),
- initialValue: webDavEnableHistory,
- ),
- SettingsTile.navigation(
- onPressed: (_) async {
- Modular.to.pushNamed('/settings/webdav/editor');
- },
- title: Text(
- 'WEBDAV配置',
- style: Theme.of(context).textTheme.titleMedium!,
- ),
- ),
- ],
+ ],
+ ),
+ SettingsSection(
+ title: const Text('WEBDAV'),
+ tiles: [
+ SettingsTile.switchTile(
+ onToggle: (value) async {
+ webDavEnable = value ?? !webDavEnable;
+ if (!WebDav().initialized && webDavEnable) {
+ try {
+ await WebDav().init();
+ } catch (e) {
+ webDavEnable = false;
+ KazumiDialog.showToast(message: 'WEBDAV初始化失败 $e');
+ }
+ }
+ if (!webDavEnable) {
+ webDavEnableHistory = false;
+ await setting.put(
+ SettingBoxKey.webDavEnableHistory, false);
+ }
+ await setting.put(SettingBoxKey.webDavEnable, webDavEnable);
+ if (mounted) {
+ setState(() {});
+ }
+ },
+ title: const Text('WEBDAV同步'),
+ initialValue: webDavEnable,
+ ),
+ SettingsTile.switchTile(
+ onToggle: (value) async {
+ if (!webDavEnable) {
+ KazumiDialog.showToast(message: '请先开启WEBDAV同步');
+ return;
+ }
+ webDavEnableHistory = value ?? !webDavEnableHistory;
+ await setting.put(
+ SettingBoxKey.webDavEnableHistory, webDavEnableHistory);
+ setState(() {});
+ },
+ title: const Text('观看记录同步'),
+ description: const Text('允许自动同步观看记录'),
+ initialValue: webDavEnableHistory,
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) async {
+ Modular.to.pushNamed('/settings/webdav/editor');
+ },
+ title: const Text('WEBDAV配置'),
),
- SettingsSection(
- bottomInfo: const Text('立即上传观看记录到WEBDAV'),
- tiles: [
- SettingsTile(
- trailing: const Icon(Icons.cloud_upload_rounded),
- onPressed: (_) {
- updateWebdav();
- },
- title: const Text('手动上传'),
- ),
- ],
+ ],
+ ),
+ SettingsSection(
+ bottomInfo: const Text('立即上传观看记录到WEBDAV'),
+ tiles: [
+ SettingsTile(
+ trailing: const Icon(Icons.cloud_upload_rounded),
+ onPressed: (_) {
+ updateWebdav();
+ },
+ title: const Text('手动上传'),
),
- SettingsSection(
- bottomInfo: const Text('立即下载观看记录到本地'),
- tiles: [
- SettingsTile(
- trailing: const Icon(Icons.cloud_download_rounded),
- onPressed: (_) {
- downloadWebdav();
- },
- title: const Text('手动下载'),
- ),
- ],
+ ],
+ ),
+ SettingsSection(
+ bottomInfo: const Text('立即下载观看记录到本地'),
+ tiles: [
+ SettingsTile(
+ trailing: const Icon(Icons.cloud_download_rounded),
+ onPressed: (_) {
+ downloadWebdav();
+ },
+ title: const Text('手动下载'),
),
],
),
- ),
+ ],
),
),
);
diff --git a/pubspec.lock b/pubspec.lock
index b2a74a35..3c2a4a8d 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -181,10 +181,10 @@ packages:
dependency: "direct main"
description:
name: card_settings_ui
- sha256: "69946704bf4e05830e4737645188f14420285063c8e15f82ef8f5708dba55df8"
+ sha256: "73670e4685d44fed8e9669e813153801825eea6f7a2845665e3a5a8631761e6c"
url: "https://pub.dev"
source: hosted
- version: "2.0.0"
+ version: "2.0.1"
characters:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 5c42b8d7..0015ba0d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -49,7 +49,7 @@ dependencies:
hive: ^2.2.3
hive_flutter: ^1.1.0
cached_network_image: ^3.4.1
- card_settings_ui: ^2.0.0
+ card_settings_ui: ^2.0.1
# fvp: ^0.28.0
# video_player: ^2.9.1