fix status bar height && status only update after mouse hover

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2022-10-19 20:53:05 +08:00
parent 32ad458b25
commit 4a2307de2f

View File

@ -55,6 +55,9 @@ class _ConnectionPageState extends State<ConnectionPage>
_updateTimer = Timer.periodic(Duration(seconds: 1), (timer) { _updateTimer = Timer.periodic(Duration(seconds: 1), (timer) {
updateStatus(); updateStatus();
}); });
_idFocusNode.addListener(() {
_idInputFocused.value = _idFocusNode.hasFocus;
});
} }
@override @override
@ -107,9 +110,8 @@ class _ConnectionPageState extends State<ConnectionPage>
).paddingOnly(left: 12.0), ).paddingOnly(left: 12.0),
), ),
), ),
const Divider(), const Divider(height: 1),
SizedBox(child: Obx(() => buildStatus())) buildStatus()
.paddingOnly(bottom: 12, top: 6),
], ],
); );
} }
@ -124,9 +126,6 @@ class _ConnectionPageState extends State<ConnectionPage>
/// UI for the remote ID TextField. /// UI for the remote ID TextField.
/// Search for a peer and connect to it if the id exists. /// Search for a peer and connect to it if the id exists.
Widget _buildRemoteIDTextField(BuildContext context) { Widget _buildRemoteIDTextField(BuildContext context) {
_idFocusNode.addListener(() {
_idInputFocused.value = _idFocusNode.hasFocus;
});
var w = Container( var w = Container(
width: 320 + 20 * 2, width: 320 + 20 * 2,
padding: const EdgeInsets.fromLTRB(20, 24, 20, 22), padding: const EdgeInsets.fromLTRB(20, 24, 20, 22),
@ -235,79 +234,73 @@ class _ConnectionPageState extends State<ConnectionPage>
var svcIsUsingPublicServer = true.obs; var svcIsUsingPublicServer = true.obs;
Widget buildStatus() { Widget buildStatus() {
final fontSize = 14.0; final em = 14.0;
final textStyle = TextStyle(fontSize: fontSize); return ConstrainedBox(
final light = Container( constraints: BoxConstraints.tightFor(height: 3 * em),
height: 8, child: Obx(() => Row(
width: 8, crossAxisAlignment: CrossAxisAlignment.center,
decoration: BoxDecoration( children: [
borderRadius: BorderRadius.circular(20), Container(
color: svcStopped.value || svcStatusCode.value == 0 height: 8,
? kColorWarn width: 8,
: (svcStatusCode.value == 1 decoration: BoxDecoration(
? Color.fromARGB(255, 50, 190, 166) borderRadius: BorderRadius.circular(4),
: Color.fromARGB(255, 224, 79, 95)), color: svcStopped.value || svcStatusCode.value == 0
), ? kColorWarn
).paddingSymmetric(horizontal: 12.0); : (svcStatusCode.value == 1
if (svcStopped.value) { ? Color.fromARGB(255, 50, 190, 166)
return Row( : Color.fromARGB(255, 224, 79, 95)),
crossAxisAlignment: CrossAxisAlignment.center, ),
children: [ ).marginSymmetric(horizontal: em),
light, Text(
Text(translate("Service is not running"), style: textStyle), svcStopped.value
TextButton( ? translate("Service is not running")
onPressed: () async { : svcStatusCode.value == 0
bool checked = await bind.mainCheckSuperUserPermission(); ? translate("connecting_status")
if (checked) { : svcStatusCode.value == -1
bind.mainSetOption(key: "stop-service", value: ""); ? translate("not_ready_status")
bind.mainSetOption(key: "access-mode", value: ""); : translate('Ready'),
} style: TextStyle(fontSize: em)),
}, // stop
child: Text(translate("Start Service"), style: textStyle)) Offstage(
], offstage: !svcStopped.value,
); child: GestureDetector(
} else { onTap: () async {
if (svcStatusCode.value == 0) { bool checked =
return Row( await bind.mainCheckSuperUserPermission();
crossAxisAlignment: CrossAxisAlignment.center, if (checked) {
children: [ bind.mainSetOption(key: "stop-service", value: "");
light, bind.mainSetOption(key: "access-mode", value: "");
Text(translate("connecting_status"), style: textStyle) }
], },
); child: Text(translate("Start Service"),
} else if (svcStatusCode.value == -1) { style: TextStyle(
return Row( decoration: TextDecoration.underline,
crossAxisAlignment: CrossAxisAlignment.center, fontSize: em)))
children: [ .marginOnly(left: em),
light, ),
Text(translate("not_ready_status"), style: textStyle) // ready && public
], Offstage(
); offstage: !(!svcStopped.value &&
} svcStatusCode.value == 1 &&
} svcIsUsingPublicServer.value),
return Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
light, Text(', ', style: TextStyle(fontSize: em)),
Text(translate('Ready'), style: textStyle), InkWell(
Offstage( onTap: onUsePublicServerGuide,
offstage: !svcIsUsingPublicServer.value, child: Text(
child: Row( translate('setup_server_tip'),
crossAxisAlignment: CrossAxisAlignment.center, style: TextStyle(
children: [ decoration: TextDecoration.underline, fontSize: em),
Text(', ', style: textStyle), ),
InkWell( )
onTap: onUsePublicServerGuide, ],
child: Text( ),
translate('setup_server_tip'), )
style: TextStyle( ],
decoration: TextDecoration.underline, )),
fontSize: fontSize),
),
)
],
))
],
); );
} }