opt. & fix

- fix: pve text color
- opt.: rm ssh tab appbar
- opt.: ssh tab only display fab on `Add` page
This commit is contained in:
lollipopkit
2024-03-22 22:52:31 +08:00
parent 7feebb8c1f
commit 2681e4eb28
9 changed files with 85 additions and 71 deletions

View File

@@ -41,7 +41,9 @@ abstract final class BioAuth {
case AuthResult.success:
// wait for animation
Future.delayed(
count >= 3 ? const Duration(milliseconds: 500) : const Duration(seconds: 1),
count >= 3
? const Duration(milliseconds: 500)
: const Duration(seconds: 1),
() => _isAuthing = false,
);
break;

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 817;
static const int build = 822;
static const String engine = "3.19.3";
static const String buildAt = "2024-03-19 16:44:04";
static const String buildAt = "2024-03-21 17:33:04";
static const int modifications = 4;
static const int script = 41;
}

View File

@@ -111,7 +111,8 @@ class _HomePageState extends State<HomePage>
return Scaffold(
drawer: _buildDrawer(),
appBar: CustomAppBar(
appBar: _AppBar(
selectIndex: _selectIndex,
centerTitle: false,
title: const Text(BuildData.name),
actions: <Widget>[
@@ -357,3 +358,27 @@ ${GithubIds.participants.map((e) => '[$e](${e.url})').join(' ')}
}
}
}
final class _AppBar extends CustomAppBar {
final ValueNotifier<int> selectIndex;
const _AppBar({
required this.selectIndex,
super.title,
super.actions,
super.centerTitle,
});
@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: selectIndex,
builder: (_, idx, __) {
if (idx == AppTab.ssh.index) {
return SizedBox(height: CustomAppBar.barHeight);
}
return super.build(context);
},
);
}
}

View File

@@ -231,19 +231,13 @@ final class _PvePageState extends State<PvePage> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const SizedBox(width: 15),
RichText(
text: TextSpan(
children: [
TextSpan(
text: _wrapNodeName(item),
style: UIs.text13Bold,
),
TextSpan(
text: ' / ${item.summary}',
style: UIs.text12Grey,
),
],
),
Text(
_wrapNodeName(item),
style: UIs.text13Bold,
),
Text(
' / ${item.summary}',
style: UIs.text12Grey,
),
const Spacer(),
_buildCtrlBtns(item),
@@ -314,19 +308,13 @@ final class _PvePageState extends State<PvePage> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const SizedBox(width: 15),
RichText(
text: TextSpan(
children: [
TextSpan(
text: _wrapNodeName(item),
style: UIs.text13Bold,
),
TextSpan(
text: ' / ${item.summary}',
style: UIs.text12Grey,
),
],
),
Text(
_wrapNodeName(item),
style: UIs.text13Bold,
),
Text(
' / ${item.summary}',
style: UIs.text12Grey,
),
const Spacer(),
_buildCtrlBtns(item),

View File

@@ -32,14 +32,14 @@ const _echoPWD = 'echo \$PWD';
class SSHPage extends StatefulWidget {
final ServerPrivateInfo spi;
final String? initCmd;
final bool pop;
final bool notFromTab;
final Function()? onSessionEnd;
const SSHPage({
super.key,
required this.spi,
this.initCmd,
this.pop = true,
this.notFromTab = true,
this.onSessionEnd,
});
@@ -129,7 +129,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
_media.padding.top,
child: Padding(
padding: EdgeInsets.only(
top: CustomAppBar.barHeight ?? 0,
top: widget.notFromTab ? CustomAppBar.barHeight ?? 0 : 0,
left: _horizonPadding,
right: _horizonPadding,
),
@@ -177,9 +177,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
Widget _buildVirtualKey() {
final rows = _virtKeysList
.map((e) => Row(
children: e.map((ee) => _buildVirtualKeyItem(ee)).toList(),
))
.map((e) => Row(children: e.map((f) => _buildVirtKeyItem(f)).toList()))
.toList();
return Column(
mainAxisSize: MainAxisSize.min,
@@ -187,7 +185,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
);
}
Widget _buildVirtualKeyItem(VirtKey item) {
Widget _buildVirtKeyItem(VirtKey item) {
var selected = false;
switch (item.key) {
case TerminalKey.control:
@@ -399,7 +397,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
}
await session.done;
if (mounted && widget.pop) {
if (mounted && widget.notFromTab) {
context.pop();
}
widget.onSessionEnd?.call();

View File

@@ -44,7 +44,7 @@ class _SSHTabPageState extends State<SSHTabPage>
floatingActionButton: ListenableBuilder(
listenable: _fabRN,
builder: (_, __) {
if (_fabRN.value == 0) return const SizedBox();
if (_fabRN.value != 0) return const SizedBox();
return FloatingActionButton(
onPressed: () => AppRoute.serverEdit().go(context),
tooltip: l10n.addAServer,
@@ -127,7 +127,7 @@ class _SSHTabPageState extends State<SSHTabPage>
_tabIds[name] = SSHPage(
key: key,
spi: spi,
pop: false,
notFromTab: false,
onSessionEnd: () {
// debugPrint("Session done received on page whose tabId = $name");
// debugPrint("key = $key");

View File

@@ -15,13 +15,14 @@ class ChoiceChipX<T> extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChoiceChip(
label: Text(label),
side: BorderSide.none,
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
labelPadding: const EdgeInsets.symmetric(horizontal: 5),
selected: state.selected(value),
onSelected: state.onSelected(value),
return Padding(
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 3),
child: ChoiceChip(
label: Text(label),
side: BorderSide.none,
selected: state.selected(value),
onSelected: state.onSelected(value),
),
);
}
}