* feat (SSH page): Added server sorting, search, and history features - Added sorting functionality to the SSH page, supporting sorting by name or date added - Added a server search feature, allowing searches by name, username, or IP address - Implemented a server access history feature, allowing users to view and clear the history - Added persistent storage for sorting options in Settings - Updated the multilingual files to support the new features * fix(ssh/tab): Fixed an issue where tabs were not refreshed after sorting Added _tabRN.notify() to refresh tabs after sorting, while also changing _TabBar from ConsumerWidget to StatelessWidget and fixing the sorting logic * fix(ssh/tab): Fixed an issue where tabs were not refreshed after sorting Added _tabRN.notify() to refresh tabs after sorting, while also changing _TabBar from ConsumerWidget to StatelessWidget and fixing the sorting logic * fix(ssh): Fixed the sorting functionality and optimized the UI display - Fixed performance issues caused by using `indexOf` during server sorting; switched to pre-built index mappings - Optimized divider colors to use theme colors - Removed unnecessary nested `Column` and `Expanded` structures - Replaced hard-coded blue with theme colors - Added error handling to display a snackbar - Ensured all `ValueNotifier` instances are properly released upon disposal
62 lines
1.4 KiB
Dart
62 lines
1.4 KiB
Dart
import 'package:fl_lib/fl_lib.dart';
|
|
import 'package:hive_ce_flutter/hive_flutter.dart';
|
|
|
|
/// index from 0 -> n : latest -> oldest
|
|
class _ListHistory {
|
|
final List _history;
|
|
final String _name;
|
|
final Box _box;
|
|
|
|
_ListHistory({required Box box, required String name})
|
|
: _box = box,
|
|
_name = name,
|
|
_history = box.get(name, defaultValue: [])!;
|
|
|
|
void add(String path) {
|
|
_history.remove(path);
|
|
_history.insert(0, path);
|
|
_box.put(_name, _history);
|
|
}
|
|
|
|
List get all => _history;
|
|
|
|
void clear() {
|
|
_history.clear();
|
|
_box.put(_name, _history);
|
|
}
|
|
}
|
|
|
|
class _MapHistory {
|
|
final Map _history;
|
|
final String _name;
|
|
final Box _box;
|
|
|
|
_MapHistory({required Box box, required String name})
|
|
: _box = box,
|
|
_name = name,
|
|
_history = box.get(name, defaultValue: <dynamic, dynamic>{})!;
|
|
|
|
void put(String id, String val) {
|
|
_history[id] = val;
|
|
_box.put(_name, _history);
|
|
}
|
|
|
|
String? fetch(String id) => _history[id];
|
|
}
|
|
|
|
class HistoryStore extends HiveStore {
|
|
HistoryStore._() : super('history');
|
|
|
|
static final instance = HistoryStore._();
|
|
|
|
late final sftpGoPath = _ListHistory(box: box, name: 'sftpPath');
|
|
|
|
late final sftpLastPath = _MapHistory(box: box, name: 'sftpLastPath');
|
|
|
|
late final sshCmds = _ListHistory(box: box, name: 'sshCmds');
|
|
|
|
late final sshServerHistory = _ListHistory(box: box, name: 'sshServerHistory');
|
|
|
|
late final writeScriptTipShown = propertyDefault('writeScriptTipShown', false);
|
|
}
|