mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
fix
This commit is contained in:
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/data/model/app/menu/server_func.dart';
|
||||
import 'package:toolbox/data/model/ssh/virtual_key.dart';
|
||||
|
||||
import '../model/app/net_view.dart';
|
||||
import '../res/default.dart';
|
||||
@@ -141,9 +140,7 @@ class SettingStore extends PersistentStore {
|
||||
|
||||
late final sshVirtKeys = listProperty(
|
||||
'sshVirtKeys',
|
||||
Defaults.sshVirtKeys,
|
||||
encoder: (val) => val.index,
|
||||
decoder: (val) => VirtKey.values[val],
|
||||
Defaults.sshVirtKeys.map((e) => e.index).toList(),
|
||||
);
|
||||
|
||||
late final netViewType = property(
|
||||
@@ -212,7 +209,7 @@ class SettingStore extends PersistentStore {
|
||||
/// Whether collapse UI items by default
|
||||
late final collapseUIDefault = property('collapseUIDefault', true);
|
||||
|
||||
late final serverFuncBtns = listProperty<ServerFuncBtn>(
|
||||
late final serverFuncBtns = listProperty(
|
||||
'serverBtns',
|
||||
[
|
||||
ServerFuncBtn.terminal,
|
||||
@@ -221,9 +218,7 @@ class SettingStore extends PersistentStore {
|
||||
ServerFuncBtn.process,
|
||||
ServerFuncBtn.pkg,
|
||||
ServerFuncBtn.snippet,
|
||||
],
|
||||
encoder: (val) => val.index,
|
||||
decoder: (val) => ServerFuncBtn.values[val],
|
||||
].map((e) => e.index).toList(),
|
||||
);
|
||||
|
||||
// Never show these settings for users
|
||||
|
||||
@@ -29,12 +29,12 @@ class _ServerDetailOrderPageState extends State<ServerFuncBtnsOrderPage> {
|
||||
|
||||
Widget _buildBody() {
|
||||
final keys_ = Stores.setting.serverFuncBtns.fetch();
|
||||
final keys = <ServerFuncBtn>[];
|
||||
final keys = <int>[];
|
||||
for (final key in keys_) {
|
||||
keys.add(key);
|
||||
}
|
||||
final disabled =
|
||||
ServerFuncBtn.values.where((e) => !keys.contains(e)).toList();
|
||||
ServerFuncBtn.values.map((e) => e.index).where((e) => !keys.contains(e)).toList();
|
||||
final allKeys = [...keys, ...disabled];
|
||||
return ReorderableListView.builder(
|
||||
padding: const EdgeInsets.all(7),
|
||||
@@ -43,7 +43,7 @@ class _ServerDetailOrderPageState extends State<ServerFuncBtnsOrderPage> {
|
||||
return CardX(
|
||||
key: ValueKey(idx),
|
||||
child: ListTile(
|
||||
title: Text(key.toStr),
|
||||
title: Text(ServerFuncBtn.values[key].toStr),
|
||||
leading: _buildCheckBox(keys, key, idx, idx < keys.length),
|
||||
trailing: isDesktop ? null : const Icon(Icons.drag_handle),
|
||||
),
|
||||
@@ -62,8 +62,8 @@ class _ServerDetailOrderPageState extends State<ServerFuncBtnsOrderPage> {
|
||||
}
|
||||
|
||||
Widget _buildCheckBox(
|
||||
List<ServerFuncBtn> keys,
|
||||
ServerFuncBtn key,
|
||||
List<int> keys,
|
||||
int key,
|
||||
int idx,
|
||||
bool value,
|
||||
) {
|
||||
|
||||
@@ -30,21 +30,22 @@ class _SSHVirtKeySettingPageState extends State<SSHVirtKeySettingPage> {
|
||||
|
||||
Widget _buildBody() {
|
||||
final keys_ = Stores.setting.sshVirtKeys.fetch();
|
||||
final keys = <VirtKey>[];
|
||||
final keys = <int>[];
|
||||
for (final key in keys_) {
|
||||
keys.add(key);
|
||||
}
|
||||
final disabled = VirtKey.values.where((e) => !keys.contains(e)).toList();
|
||||
final disabled = VirtKey.values.map((e) => e.index).where((e) => !keys.contains(e)).toList();
|
||||
final allKeys = [...keys, ...disabled];
|
||||
return ReorderableListView.builder(
|
||||
padding: const EdgeInsets.all(7),
|
||||
itemBuilder: (_, idx) {
|
||||
final key = allKeys[idx];
|
||||
final help = key.help;
|
||||
final item = VirtKey.values[key];
|
||||
final help = item.help;
|
||||
return CardX(
|
||||
key: ValueKey(idx),
|
||||
child: ListTile(
|
||||
title: _buildTitle(key),
|
||||
title: _buildTitle(item),
|
||||
subtitle: help == null ? null : Text(help, style: UIs.textGrey),
|
||||
leading: _buildCheckBox(keys, key, idx, idx < keys.length),
|
||||
trailing: isDesktop ? null : const Icon(Icons.drag_handle),
|
||||
@@ -75,7 +76,7 @@ class _SSHVirtKeySettingPageState extends State<SSHVirtKeySettingPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCheckBox(List<VirtKey> keys, VirtKey key, int idx, bool value) {
|
||||
Widget _buildCheckBox(List<int> keys, int key, int idx, bool value) {
|
||||
return Checkbox(
|
||||
value: value,
|
||||
onChanged: (val) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/core/extension/ssh_client.dart';
|
||||
import 'package:toolbox/core/extension/uint8list.dart';
|
||||
import 'package:toolbox/core/extension/widget.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/core/utils/platform/path.dart';
|
||||
import 'package:toolbox/data/model/app/menu/server_func.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:toolbox/data/res/ui.dart';
|
||||
|
||||
import '../../core/route.dart';
|
||||
import '../../core/utils/server.dart';
|
||||
@@ -67,43 +69,30 @@ class ServerFuncBtns extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// return Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
// children: ServerTabMenuType.values
|
||||
// .map(
|
||||
// (e) => Stores.setting.serverFuncBtnsDisplayName.fetch()
|
||||
// ? Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// IconButton(
|
||||
// onPressed: () => _onTapMoreBtns(e, spi, context),
|
||||
// padding: EdgeInsets.zero,
|
||||
// tooltip: e.name,
|
||||
// icon: Icon(e.icon, size: iconSize ?? 15),
|
||||
// ),
|
||||
// Text(e.toStr, style: UIs.textSize9Grey)
|
||||
// ],
|
||||
// )
|
||||
// : IconButton(
|
||||
// onPressed: () => _onTapMoreBtns(e, spi, context),
|
||||
// padding: EdgeInsets.zero,
|
||||
// tooltip: e.name,
|
||||
// icon: Icon(e.icon, size: iconSize ?? 15),
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// );
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: Stores.setting.serverFuncBtns
|
||||
.fetch()
|
||||
.map((e) => ServerFuncBtn.values[e])
|
||||
.map(
|
||||
(e) => IconButton(
|
||||
onPressed: () => _onTapMoreBtns(e, spi, context),
|
||||
padding: EdgeInsets.zero,
|
||||
tooltip: e.toStr,
|
||||
icon: Icon(e.icon, size: iconSize ?? 15),
|
||||
),
|
||||
(e) => Stores.setting.moveOutServerTabFuncBtns.fetch()
|
||||
? IconButton(
|
||||
onPressed: () => _onTapMoreBtns(e, spi, context),
|
||||
padding: EdgeInsets.zero,
|
||||
tooltip: e.toStr,
|
||||
icon: Icon(e.icon, size: iconSize ?? 15),
|
||||
)
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => _onTapMoreBtns(e, spi, context),
|
||||
padding: EdgeInsets.zero,
|
||||
icon: Icon(e.icon, size: iconSize ?? 15),
|
||||
),
|
||||
Text(e.toStr, style: UIs.text11Grey)
|
||||
],
|
||||
).padding(const EdgeInsets.only(bottom: 13)),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user