mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
apply font to ssh term
This commit is contained in:
@@ -443,8 +443,10 @@ class _ServerPageState extends State<ServerPage>
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
await GetIt.I.allReady();
|
||||
await _serverProvider.loadLocalData();
|
||||
await _serverProvider.refreshData();
|
||||
_serverProvider.startAutoRefresh();
|
||||
if (_serverProvider.servers.isEmpty) {
|
||||
await _serverProvider.loadLocalData();
|
||||
await _serverProvider.refreshData();
|
||||
_serverProvider.startAutoRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
|
||||
import '../../core/utils/misc.dart';
|
||||
import '../../core/utils/platform.dart';
|
||||
@@ -448,18 +451,52 @@ class _SettingPageState extends State<SettingPage> {
|
||||
}
|
||||
|
||||
Widget _buildFont() {
|
||||
return ListTile(
|
||||
return ExpansionTile(
|
||||
title: Text(_s.chooseFontFile),
|
||||
subtitle: Text(getFileName(_setting.fontPath.fetch()) ?? _s.notSelected),
|
||||
trailing: TextButton(
|
||||
onPressed: () async {
|
||||
final path = await pickOneFile();
|
||||
if (path != null) {
|
||||
_setting.fontPath.put(path);
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
child: Text(_s.pickFile)),
|
||||
trailing: Text(getFileName(_setting.fontPath.fetch()) ?? _s.notSelected),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () async => pickFontFile(),
|
||||
child: Text(_s.pickFile),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => setState(() {
|
||||
_setting.fontPath.delete();
|
||||
showSnackBarWithAction(
|
||||
context,
|
||||
'${_s.success}\n${_s.needRestart}',
|
||||
_s.restart,
|
||||
() => rebuildAll(context),
|
||||
);
|
||||
}),
|
||||
child: Text(_s.clear),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> pickFontFile() async {
|
||||
final path = await pickOneFile();
|
||||
if (path != null) {
|
||||
final fontDir_ = await fontDir;
|
||||
final fontFile = File(path);
|
||||
final newPath = '${fontDir_.path}/${path.split('/').last}';
|
||||
await fontFile.copy(newPath);
|
||||
_setting.fontPath.put(newPath);
|
||||
setState(() {});
|
||||
showSnackBarWithAction(
|
||||
context,
|
||||
'${_s.success}\n${_s.needRestart}',
|
||||
_s.restart,
|
||||
() => rebuildAll(context),
|
||||
);
|
||||
return;
|
||||
}
|
||||
showSnackBar(context, Text(_s.failed));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class _SFTPDownloadingPageState extends State<SFTPDownloadingPage> {
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
return Consumer<SftpDownloadProvider>(builder: (__, pro, _) {
|
||||
return Consumer<SftpProvider>(builder: (__, pro, _) {
|
||||
if (pro.status.isEmpty) {
|
||||
return Center(
|
||||
child: Text(_s.sftpNoDownloadTask),
|
||||
|
||||
@@ -305,7 +305,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
final local = '${(await sftpDownloadDir).path}$remotePath';
|
||||
final pubKeyId = widget.spi.pubKeyId;
|
||||
|
||||
locator<SftpDownloadProvider>().add(
|
||||
locator<SftpProvider>().add(
|
||||
DownloadItem(
|
||||
widget.spi,
|
||||
remotePath,
|
||||
|
||||
@@ -34,6 +34,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
late final _terminal = Terminal(inputHandler: _keyboard);
|
||||
SSHClient? _client;
|
||||
final _keyboard = locator<VirtualKeyboard>();
|
||||
final _setting = locator<SettingStore>();
|
||||
late MediaQueryData _media;
|
||||
final _virtualKeyboardHeight = 57.0;
|
||||
final TerminalController _terminalController = TerminalController();
|
||||
@@ -47,7 +48,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final termColorIdx = locator<SettingStore>().termColorIdx.fetch()!;
|
||||
final termColorIdx = _setting.termColorIdx.fetch()!;
|
||||
_termColors = TerminalColorsPlatform.values[termColorIdx].colors;
|
||||
initTerminal();
|
||||
}
|
||||
@@ -149,6 +150,8 @@ class _SSHPageState extends State<SSHPage> {
|
||||
_terminal,
|
||||
controller: _terminalController,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textStyle: TerminalStyle.fromTextStyle(
|
||||
TextStyle(fontFamily: getFileName(_setting.fontPath.fetch()))),
|
||||
theme: termTheme,
|
||||
deleteDetection: isIOS,
|
||||
onTapUp: _onTapUp,
|
||||
|
||||
32
lib/view/widget/rebuild.dart
Normal file
32
lib/view/widget/rebuild.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RebuildWidget extends StatefulWidget {
|
||||
const RebuildWidget({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
static void restartApp(BuildContext context) {
|
||||
context.findAncestorStateOfType<_RebuildWidgetState>()?.restartApp();
|
||||
}
|
||||
|
||||
@override
|
||||
_RebuildWidgetState createState() => _RebuildWidgetState();
|
||||
}
|
||||
|
||||
class _RebuildWidgetState extends State<RebuildWidget> {
|
||||
Key key = UniqueKey();
|
||||
|
||||
void restartApp() {
|
||||
setState(() {
|
||||
key = UniqueKey();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return KeyedSubtree(
|
||||
key: key,
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user