fix web and multi platform adaptation
This commit is contained in:
parent
98d8689d7b
commit
8736d37605
@ -9,6 +9,7 @@ var isIOS = false;
|
||||
var isWeb = false;
|
||||
var isDesktop = false;
|
||||
var version = "";
|
||||
int androidVersion = 0;
|
||||
|
||||
typedef F = String Function(String);
|
||||
typedef FMethod = String Function(String, dynamic);
|
||||
|
@ -18,20 +18,26 @@ Future<Null> main() async {
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final analytics = FirebaseAnalytics();
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: FFI.ffiModel),
|
||||
ChangeNotifierProvider.value(value: FFI.imageModel),
|
||||
ChangeNotifierProvider.value(value: FFI.cursorModel),
|
||||
ChangeNotifierProvider.value(value: FFI.canvasModel),
|
||||
ChangeNotifierProvider.value(value: FFI.serverModel),
|
||||
final providers = [
|
||||
ChangeNotifierProvider.value(value: FFI.ffiModel),
|
||||
ChangeNotifierProvider.value(value: FFI.imageModel),
|
||||
ChangeNotifierProvider.value(value: FFI.cursorModel),
|
||||
ChangeNotifierProvider.value(value: FFI.canvasModel),
|
||||
];
|
||||
if (!isWeb) {
|
||||
providers.addAll([
|
||||
ChangeNotifierProvider.value(value: FFI.chatModel),
|
||||
ChangeNotifierProvider.value(value: FFI.fileModel),
|
||||
],
|
||||
]);
|
||||
if (isAndroid) {
|
||||
providers.add(ChangeNotifierProvider.value(value: FFI.serverModel));
|
||||
}
|
||||
}
|
||||
return MultiProvider(
|
||||
providers: providers,
|
||||
child: MaterialApp(
|
||||
navigatorKey: globalKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
@ -40,7 +46,7 @@ class App extends StatelessWidget {
|
||||
primarySwatch: Colors.blue,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
),
|
||||
home: HomePage(),
|
||||
home: isWeb ? WebHomePage() : HomePage(),
|
||||
navigatorObservers: [
|
||||
FirebaseAnalyticsObserver(analytics: analytics),
|
||||
],
|
||||
|
@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/pages/chat_page.dart';
|
||||
|
||||
import 'model.dart';
|
||||
import 'native_model.dart';
|
||||
|
||||
class ChatModel with ChangeNotifier {
|
||||
// -1作为客户端模式的id,客户端模式下此id唯一
|
||||
@ -51,12 +50,12 @@ class ChatModel with ChangeNotifier {
|
||||
if (message.text != null && message.text!.isNotEmpty) {
|
||||
_messages[_currentID]?.add(message);
|
||||
if (_currentID == clientModeID) {
|
||||
PlatformFFI.setByName("chat_client_mode", message.text!);
|
||||
FFI.setByName("chat_client_mode", message.text!);
|
||||
} else {
|
||||
final msg = Map()
|
||||
..["id"] = _currentID
|
||||
..["text"] = message.text!;
|
||||
PlatformFFI.setByName("chat_server_mode", jsonEncode(msg));
|
||||
FFI.setByName("chat_server_mode", jsonEncode(msg));
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
|
@ -24,7 +24,6 @@ class PlatformFFI {
|
||||
static Pointer<RgbaFrame>? _lastRgbaFrame;
|
||||
static String _dir = '';
|
||||
static String _homeDir = '';
|
||||
static int? _androidVersion;
|
||||
static F2? _getByName;
|
||||
static F3? _setByName;
|
||||
static F4? _freeRgba;
|
||||
@ -49,8 +48,6 @@ class PlatformFFI {
|
||||
return packageInfo.version;
|
||||
}
|
||||
|
||||
static int? get androidVersion => _androidVersion;
|
||||
|
||||
static String getByName(String name, [String arg = '']) {
|
||||
if (_getByName == null) return '';
|
||||
var a = name.toNativeUtf8();
|
||||
@ -97,7 +94,7 @@ class PlatformFFI {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
name = '${androidInfo.brand}-${androidInfo.model}';
|
||||
id = androidInfo.id.hashCode.toString();
|
||||
_androidVersion = androidInfo.version.sdkInt;
|
||||
androidVersion = androidInfo.version.sdkInt;
|
||||
} else {
|
||||
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
name = iosInfo.utsname.machine;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/models/native_model.dart';
|
||||
import '../common.dart';
|
||||
import '../pages/server_page.dart';
|
||||
import 'model.dart';
|
||||
@ -71,7 +70,7 @@ class ServerModel with ChangeNotifier {
|
||||
|
||||
toggleInput(){
|
||||
if(_inputOk){
|
||||
PlatformFFI.invokeMethod("stop_input");
|
||||
FFI.invokeMethod("stop_input");
|
||||
}else{
|
||||
showInputWarnAlert();
|
||||
}
|
||||
|
@ -20,12 +20,20 @@ class HomePage extends StatefulWidget {
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
var _selectedIndex = 0;
|
||||
final List<PageShape> _pages = [
|
||||
ConnectionPage(),
|
||||
chatPage,
|
||||
ServerPage(),
|
||||
SettingsPage()
|
||||
];
|
||||
final List<PageShape> _pages = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_pages.addAll([
|
||||
ConnectionPage(),
|
||||
chatPage,
|
||||
]);
|
||||
if(isAndroid){
|
||||
_pages.add(ServerPage());
|
||||
}
|
||||
_pages.add(SettingsPage());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -58,7 +66,7 @@ class _HomePageState extends State<HomePage> {
|
||||
unselectedItemColor: MyTheme.darkGray,
|
||||
onTap: (index) => setState(() {
|
||||
// close chat overlay when go chat page
|
||||
if(index == 1 && _selectedIndex!=index){
|
||||
if (index == 1 && _selectedIndex != index) {
|
||||
hideChatIconOverlay();
|
||||
hideChatWindowOverlay();
|
||||
}
|
||||
@ -69,3 +77,20 @@ class _HomePageState extends State<HomePage> {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class WebHomePage extends StatelessWidget {
|
||||
final connectionPage = ConnectionPage();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: MyTheme.grayBg,
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text("RustDesk"),
|
||||
actions: connectionPage.appBarActions,
|
||||
),
|
||||
body: connectionPage,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../common.dart';
|
||||
import '../models/native_model.dart';
|
||||
import '../models/server_model.dart';
|
||||
import 'home_page.dart';
|
||||
import '../models/model.dart';
|
||||
@ -156,7 +155,6 @@ class _PermissionCheckerState extends State<PermissionChecker> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final serverModel = Provider.of<ServerModel>(context);
|
||||
final androidVersion = PlatformFFI.androidVersion ?? 0;
|
||||
final hasAudioPermission = androidVersion>=30;
|
||||
return PaddingCard(
|
||||
title: translate("Configuration Permissions"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user