mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: full screen jitter
This commit is contained in:
@@ -486,6 +486,18 @@ abstract class S {
|
||||
/// **'Full screen mode'**
|
||||
String get fullScreen;
|
||||
|
||||
/// No description provided for @fullScreenJitter.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Full screen jitter'**
|
||||
String get fullScreenJitter;
|
||||
|
||||
/// No description provided for @fullScreenJitterHelp.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'To avoid screen burn-in'**
|
||||
String get fullScreenJitterHelp;
|
||||
|
||||
/// No description provided for @getPushTokenFailed.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -215,6 +215,12 @@ class SDe extends S {
|
||||
@override
|
||||
String get fullScreen => 'Full screen mode';
|
||||
|
||||
@override
|
||||
String get fullScreenJitter => 'Full screen jitter';
|
||||
|
||||
@override
|
||||
String get fullScreenJitterHelp => 'To avoid screen burn-in';
|
||||
|
||||
@override
|
||||
String get getPushTokenFailed => 'Push-Token kann nicht abgerufen werden';
|
||||
|
||||
|
||||
@@ -215,6 +215,12 @@ class SEn extends S {
|
||||
@override
|
||||
String get fullScreen => 'Full screen mode';
|
||||
|
||||
@override
|
||||
String get fullScreenJitter => 'Full screen jitter';
|
||||
|
||||
@override
|
||||
String get fullScreenJitterHelp => 'To avoid screen burn-in';
|
||||
|
||||
@override
|
||||
String get getPushTokenFailed => 'Can\'t fetch push token';
|
||||
|
||||
|
||||
@@ -215,6 +215,12 @@ class SZh extends S {
|
||||
@override
|
||||
String get fullScreen => '全屏模式';
|
||||
|
||||
@override
|
||||
String get fullScreenJitter => '全屏模式抖动';
|
||||
|
||||
@override
|
||||
String get fullScreenJitterHelp => '防止烧屏';
|
||||
|
||||
@override
|
||||
String get getPushTokenFailed => '未能获取到推送token';
|
||||
|
||||
|
||||
@@ -69,4 +69,7 @@ class SettingStore extends PersistentStore {
|
||||
|
||||
StoreProperty<bool> get fullScreen =>
|
||||
property('fullScreen', defaultValue: false);
|
||||
|
||||
StoreProperty<bool> get fullScreenJitter =>
|
||||
property('fullScreenJitter', defaultValue: true);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
"fontSize": "Font size",
|
||||
"foundNUpdate": "Found {count} update",
|
||||
"fullScreen": "Full screen mode",
|
||||
"fullScreenJitter": "Full screen jitter",
|
||||
"fullScreenJitterHelp": "To avoid screen burn-in",
|
||||
"getPushTokenFailed": "Can't fetch push token",
|
||||
"gettingToken": "Getting token...",
|
||||
"goto": "Go to",
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
"fontSize": "字体大小",
|
||||
"foundNUpdate": "找到 {count} 个更新",
|
||||
"fullScreen": "全屏模式",
|
||||
"fullScreenJitter": "全屏模式抖动",
|
||||
"fullScreenJitterHelp": "防止烧屏",
|
||||
"getPushTokenFailed": "未能获取到推送token",
|
||||
"gettingToken": "正在获取Token...",
|
||||
"goto": "前往",
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:circle_chart/circle_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -28,10 +31,11 @@ class FullScreenPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FullScreenPageState extends State<FullScreenPage>
|
||||
with AfterLayoutMixin, AutomaticKeepAliveClientMixin {
|
||||
with AfterLayoutMixin {
|
||||
late S _s;
|
||||
late MediaQueryData _media;
|
||||
late ThemeData _theme;
|
||||
late Timer _timer;
|
||||
|
||||
final _pageController = PageController(initialPage: 0);
|
||||
final _serverProvider = locator<ServerProvider>();
|
||||
@@ -40,6 +44,13 @@ class _FullScreenPageState extends State<FullScreenPage>
|
||||
void initState() {
|
||||
super.initState();
|
||||
hideStatusBar();
|
||||
_timer = Timer.periodic(const Duration(minutes: 1), (_) => setState(() {}));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_timer.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -50,22 +61,35 @@ class _FullScreenPageState extends State<FullScreenPage>
|
||||
_theme = Theme.of(context);
|
||||
}
|
||||
|
||||
// x = _media.size.width * 0.1
|
||||
// r = Random().nextDouble()
|
||||
// Return [-x * r, x * r]
|
||||
double get _offset {
|
||||
final x = _media.size.width * 0.03;
|
||||
var r = Random().nextDouble();
|
||||
final n = Random().nextBool() ? -1 : 1;
|
||||
return n * x * r;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final offset = Offset(_offset, _offset);
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: RotatedBox(
|
||||
quarterTurns: 3,
|
||||
child: Stack(
|
||||
children: [
|
||||
_buildMain(),
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
child: _buildSettingBtn(),
|
||||
),
|
||||
],
|
||||
child: Transform.translate(
|
||||
offset: offset,
|
||||
child: Stack(
|
||||
children: [
|
||||
_buildMain(),
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
child: _buildSettingBtn(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -124,40 +148,44 @@ class _FullScreenPageState extends State<FullScreenPage>
|
||||
'server detail page',
|
||||
).go(context),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(top: 0, left: 0, right: 0, child: _buildServerCardTitle(ss, cs, spi)),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: _media.size.width * 0.1),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildPercentCircle(ss.cpu.usedPercent()),
|
||||
_buildPercentCircle(ss.mem.usedPercent * 100),
|
||||
_buildIOData(
|
||||
'Conn:\n${ss.tcp.maxConn}', 'Fail:\n${ss.tcp.fail}'),
|
||||
_buildIOData(
|
||||
'Total:\n${rootDisk.size}',
|
||||
'Used:\n${rootDisk.usedPercent}%',
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: _media.size.width * 0.1),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildExplainText('CPU'),
|
||||
_buildExplainText('Mem'),
|
||||
_buildExplainText('Net'),
|
||||
_buildExplainText('Disk'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: _buildServerCardTitle(ss, cs, spi)),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: _media.size.width * 0.1),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildPercentCircle(ss.cpu.usedPercent()),
|
||||
_buildPercentCircle(ss.mem.usedPercent * 100),
|
||||
_buildIOData(
|
||||
'Conn:\n${ss.tcp.maxConn}', 'Fail:\n${ss.tcp.fail}'),
|
||||
_buildIOData(
|
||||
'Total:\n${rootDisk.size}',
|
||||
'Used:\n${rootDisk.usedPercent}%',
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: _media.size.width * 0.1),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildExplainText('CPU'),
|
||||
_buildExplainText('Mem'),
|
||||
_buildExplainText('Net'),
|
||||
_buildExplainText('Disk'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -172,6 +200,7 @@ class _FullScreenPageState extends State<FullScreenPage>
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
height13,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -311,9 +340,6 @@ class _FullScreenPageState extends State<FullScreenPage>
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
await GetIt.I.allReady();
|
||||
|
||||
@@ -128,6 +128,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildLaunchPage(),
|
||||
_buildCheckUpdate(),
|
||||
_buildFullScreen(),
|
||||
_buildFullScreenJitter(),
|
||||
];
|
||||
if (isIOS) {
|
||||
children.add(_buildPushToken());
|
||||
@@ -672,4 +673,12 @@ class _SettingPageState extends State<SettingPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFullScreenJitter() {
|
||||
return ListTile(
|
||||
title: Text(_s.fullScreenJitter),
|
||||
subtitle: Text(_s.fullScreenJitterHelp, style: grey),
|
||||
trailing: buildSwitch(context, _setting.fullScreenJitter),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user