Do not show status bar if the screen is small

This commit is contained in:
Calcitem 2021-07-17 23:08:26 +08:00
parent b7ba2d6f0d
commit ed183913a8
No known key found for this signature in database
GPG Key ID: F2F7C29E054CFB80
5 changed files with 25 additions and 6 deletions

View File

@ -56,7 +56,7 @@ class Config {
static double boardInnerLineWidth = 2.0;
static double pieceWidth = 0.9;
static double fontSize = 16.0;
static double boardTop = 75.0;
static double boardTop = isLargeScreen()? 75.0 : 36.0;
static double animationDuration = 0.0;
// Color
@ -126,7 +126,7 @@ class Config {
Config.boardInnerLineWidth = settings['BoardInnerLineWidth'] ?? 2;
Config.pieceWidth = settings['PieceWidth'] ?? 0.9;
Config.fontSize = settings['FontSize'] ?? 16.0;
Config.boardTop = settings['BoardTop'] ?? 75;
Config.boardTop = settings['BoardTop'] ?? (isLargeScreen()? 75 :36);
Config.animationDuration = settings['AnimationDuration'] ?? 0;
// Color

View File

@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:ui';
class Constants {
static String appName = "Mill";
static String authorAccount = "calcitem";
@ -64,4 +66,13 @@ class Constants {
static String githubThanksURL = "$githubRepoWiKiURL/thanks";
static String giteeThanksURL = "$giteeRepoWiKiURL/thanks";
static final windowHeight = window.physicalSize.height;
}
bool isSmallScreen() {
return Constants.windowHeight <= 800;
}
bool isLargeScreen() {
return !isSmallScreen();
}

View File

@ -18,6 +18,7 @@
import 'dart:async';
import 'dart:io';
import 'dart:ui';
import 'package:catcher/catcher.dart';
import 'package:double_back_to_close_app/double_back_to_close_app.dart';
@ -90,11 +91,14 @@ Future<void> main() async {
profileConfig: profileOptions,
);
print(window.physicalSize);
print(Constants.windowHeight);
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown],
);
if (Platform.isAndroid) {
if (Platform.isAndroid && isLargeScreen()) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
@ -106,7 +110,9 @@ Future<void> main() async {
);
}
//SystemChrome.setEnabledSystemUIOverlays([]);
if (isSmallScreen()) {
SystemChrome.setEnabledSystemUIOverlays([]);
}
}
RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:sanmill/common/config.dart';
import 'package:sanmill/common/constants.dart';
import 'package:sanmill/style/colors.dart';
class AppTheme {
@ -105,7 +106,7 @@ class AppTheme {
height: 1.5,
color: moveHistoryTextColor);
static double boardTop = 75.0;
static double boardTop = isLargeScreen()? 75.0 : 36.0;
static double boardMargin = 10.0;
static double boardScreenPaddingH = 10.0;
static double boardBorderRadius = 5.0;

View File

@ -21,6 +21,7 @@ import 'dart:async';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/material.dart';
import 'package:sanmill/common/config.dart';
import 'package:sanmill/common/constants.dart';
import 'package:sanmill/generated/l10n.dart';
import 'package:sanmill/l10n/resources.dart';
import 'package:sanmill/style/app_theme.dart';
@ -183,7 +184,7 @@ class _HomeDrawerState extends State<HomeDrawer> {
children: <Widget>[
animatedBuilder,
Padding(
padding: const EdgeInsets.only(top: 30, left: 4),
padding: EdgeInsets.only(top: (isLargeScreen() ? 30 : 8), left: 4),
child: animatedTextKit,
),
],