mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
#35 new: servers tab reorderable
This commit is contained in:
@@ -360,7 +360,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 295;
|
||||
CURRENT_PROJECT_VERSION = 300;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -368,7 +368,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.295;
|
||||
MARKETING_VERSION = 1.0.300;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -491,7 +491,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 295;
|
||||
CURRENT_PROJECT_VERSION = 300;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -499,7 +499,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.295;
|
||||
MARKETING_VERSION = 1.0.300;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -516,7 +516,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 295;
|
||||
CURRENT_PROJECT_VERSION = 300;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -524,7 +524,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.295;
|
||||
MARKETING_VERSION = 1.0.300;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
||||
@@ -18,10 +18,31 @@ import '../store/server.dart';
|
||||
import '../store/setting.dart';
|
||||
|
||||
typedef ServersMap = Map<String, Server>;
|
||||
typedef ServerOrder = List<String>;
|
||||
|
||||
extension ServerOrderX on ServerOrder {
|
||||
void move(int oldIndex, int newIndex) {
|
||||
if (oldIndex == newIndex) return;
|
||||
if (oldIndex < newIndex) {
|
||||
newIndex -= 1;
|
||||
}
|
||||
final item = this[oldIndex];
|
||||
removeAt(oldIndex);
|
||||
insert(newIndex, item);
|
||||
locator<SettingStore>().serverOrder.put(this);
|
||||
}
|
||||
|
||||
void update(String id, String newId) {
|
||||
final index = indexOf(id);
|
||||
if (index == -1) return;
|
||||
this[index] = newId;
|
||||
}
|
||||
}
|
||||
|
||||
class ServerProvider extends BusyProvider {
|
||||
final ServersMap _servers = {};
|
||||
ServersMap get servers => _servers;
|
||||
final ServerOrder serverOrder = [];
|
||||
|
||||
final _limiter = TryLimiter();
|
||||
|
||||
@@ -29,14 +50,21 @@ class ServerProvider extends BusyProvider {
|
||||
|
||||
final _logger = Logger('SERVER');
|
||||
|
||||
final _store = locator<ServerStore>();
|
||||
final _serverStore = locator<ServerStore>();
|
||||
final _settingStore = locator<SettingStore>();
|
||||
|
||||
Future<void> loadLocalData() async {
|
||||
setBusyState(true);
|
||||
final infos = _store.fetch();
|
||||
final infos = _serverStore.fetch();
|
||||
for (final info in infos) {
|
||||
_servers[info.id] = genServer(info);
|
||||
}
|
||||
final serverOrder_ = _settingStore.serverOrder.fetch();
|
||||
if (serverOrder_ != null) {
|
||||
serverOrder.addAll(serverOrder_);
|
||||
} else {
|
||||
serverOrder.addAll(_servers.keys);
|
||||
}
|
||||
setBusyState(false);
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -107,14 +135,18 @@ class ServerProvider extends BusyProvider {
|
||||
void addServer(ServerPrivateInfo spi) {
|
||||
_servers[spi.id] = genServer(spi);
|
||||
notifyListeners();
|
||||
_store.put(spi);
|
||||
_serverStore.put(spi);
|
||||
serverOrder.add(spi.id);
|
||||
_settingStore.serverOrder.put(serverOrder);
|
||||
refreshData(spi: spi);
|
||||
}
|
||||
|
||||
void delServer(String id) {
|
||||
_servers.remove(id);
|
||||
serverOrder.remove(id);
|
||||
_settingStore.serverOrder.put(serverOrder);
|
||||
notifyListeners();
|
||||
_store.delete(id);
|
||||
_serverStore.delete(id);
|
||||
}
|
||||
|
||||
Future<void> updateServer(
|
||||
@@ -122,9 +154,11 @@ class ServerProvider extends BusyProvider {
|
||||
ServerPrivateInfo newSpi,
|
||||
) async {
|
||||
_servers.remove(old.id);
|
||||
_store.update(old, newSpi);
|
||||
_serverStore.update(old, newSpi);
|
||||
_servers[newSpi.id] = genServer(newSpi);
|
||||
_servers[newSpi.id]?.client = await genClient(newSpi);
|
||||
serverOrder.update(old.id, newSpi.id);
|
||||
_settingStore.serverOrder.put(serverOrder);
|
||||
await refreshData(spi: newSpi);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 295;
|
||||
static const int build = 300;
|
||||
static const String engine = "3.10.0";
|
||||
static const String buildAt = "2023-05-11 12:17:12.803987";
|
||||
static const int modifications = 3;
|
||||
static const String buildAt = "2023-05-12 16:42:47.988995";
|
||||
static const int modifications = 1;
|
||||
}
|
||||
|
||||
@@ -39,4 +39,8 @@ class SettingStore extends PersistentStore {
|
||||
|
||||
/// Backgroud running (Android)
|
||||
StoreProperty<bool> get bgRun => property('bgRun', defaultValue: isAndroid);
|
||||
|
||||
// Server order
|
||||
StoreProperty<List<String>> get serverOrder =>
|
||||
property('serverOrder', defaultValue: null);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
await _serverProvider.refreshData(onlyFailed: true),
|
||||
child: Consumer<ServerProvider>(
|
||||
builder: (_, pro, __) {
|
||||
if (pro.servers.isEmpty) {
|
||||
if (pro.serverOrder.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
_s.serverTabEmpty,
|
||||
@@ -91,21 +91,15 @@ class _ServerPageState extends State<ServerPage>
|
||||
),
|
||||
);
|
||||
}
|
||||
final keys = pro.servers.keys.toList();
|
||||
return ListView.separated(
|
||||
return ReorderableListView(
|
||||
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
|
||||
controller: ScrollController(),
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemBuilder: (ctx, idx) {
|
||||
if (idx == pro.servers.length) {
|
||||
return SizedBox(height: _media.padding.bottom);
|
||||
}
|
||||
return _buildEachServerCard(pro.servers[keys[idx]]);
|
||||
},
|
||||
itemCount: pro.servers.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
onReorder: (oldIndex, newIndex) => setState(() {
|
||||
pro.serverOrder.move(oldIndex, newIndex);
|
||||
}),
|
||||
children: pro.serverOrder
|
||||
.map((e) => _buildEachServerCard(pro.servers[e]))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -116,21 +110,18 @@ class _ServerPageState extends State<ServerPage>
|
||||
if (si == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return GestureDetector(
|
||||
onLongPress: () => AppRoute(
|
||||
ServerEditPage(spi: si.spi),
|
||||
'Edit server info page',
|
||||
).go(context),
|
||||
child: RoundRectCard(
|
||||
Padding(
|
||||
return RoundRectCard(
|
||||
GestureDetector(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(13),
|
||||
child: _buildRealServerCard(si.status, si.spi.name, si.state, si.spi),
|
||||
),
|
||||
onTap: () => AppRoute(
|
||||
ServerDetailPage(si.spi.id),
|
||||
'server detail page',
|
||||
).go(context),
|
||||
),
|
||||
onTap: () => AppRoute(
|
||||
ServerDetailPage(si.spi.id),
|
||||
'server detail page',
|
||||
).go(context),
|
||||
key: Key(si.spi.id),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ PODS:
|
||||
|
||||
DEPENDENCIES:
|
||||
- FlutterMacOS (from `Flutter/ephemeral`)
|
||||
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos`)
|
||||
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
|
||||
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
|
||||
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
|
||||
|
||||
@@ -18,7 +18,7 @@ EXTERNAL SOURCES:
|
||||
FlutterMacOS:
|
||||
:path: Flutter/ephemeral
|
||||
path_provider_foundation:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
|
||||
share_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos
|
||||
url_launcher_macos:
|
||||
|
||||
Reference in New Issue
Block a user