new: PlatformType

This commit is contained in:
lollipopkit
2023-03-13 12:02:48 +08:00
parent 4c4153ef98
commit c2e822f49d
18 changed files with 197 additions and 113 deletions

View File

@@ -416,6 +416,7 @@ class _SettingPageState extends State<SettingPage> {
onPressed: () {
if (_pushToken != null) {
copy(_pushToken!);
showSnackBar(context, Text(_s.success));
} else {
showSnackBar(context, Text(_s.getPushTokenFailed));
}
@@ -424,15 +425,26 @@ class _SettingPageState extends State<SettingPage> {
subtitle: FutureBuilder<String?>(
future: getToken(),
builder: (context, snapshot) {
if (snapshot.hasData) {
_pushToken = snapshot.data;
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return const Text('Getting Token...');
default:
var text = _pushToken;
if (snapshot.hasError) {
text = 'Error: ${snapshot.error}';
}
_pushToken = snapshot.data;
if (_pushToken == null) {
text = 'Null token';
}
return Text(
text!,
style: grey,
overflow: TextOverflow.ellipsis,
maxLines: 1,
);
}
return Text(
_pushToken ?? 'Getting Token...',
style: grey,
overflow: TextOverflow.ellipsis,
maxLines: 1,
);
},
),
);

View File

@@ -1,5 +1,4 @@
import 'dart:convert';
import 'dart:io';
import 'package:dartssh2/dartssh2.dart';
import 'package:flutter/foundation.dart';
@@ -9,6 +8,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:provider/provider.dart';
import 'package:xterm/xterm.dart' hide TerminalColors;
import '../../core/utils/platform.dart';
import '../../data/model/ssh/terminal_color.dart';
import '../../core/utils/misc.dart';
import '../../core/utils/ui.dart';
@@ -111,7 +111,7 @@ class _SSHPageState extends State<SSHPage> {
body: _buildBody(termTheme.toTerminalTheme(_termColors)),
bottomNavigationBar: _buildBottom(termTheme.background),
);
if (Platform.isIOS) {
if (isIOS) {
child = AnnotatedRegion(
value: _isDark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
child: child,
@@ -131,7 +131,7 @@ class _SSHPageState extends State<SSHPage> {
controller: _terminalController,
keyboardType: TextInputType.visiblePassword,
theme: termTheme,
deleteDetection: Platform.isIOS,
deleteDetection: isIOS,
onTapUp: _onTapUp,
autoFocus: true,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,