2022-08-17 16:28:36 +03:00
import ' package:flutter/material.dart ' ;
2022-09-13 16:38:47 +03:00
import ' package:flutter_hbb/common.dart ' ;
2022-08-17 16:28:36 +03:00
import ' package:flutter_hbb/consts.dart ' ;
2022-09-13 16:38:47 +03:00
import ' package:flutter_hbb/desktop/pages/server_page.dart ' ;
2022-10-20 17:05:34 +03:00
import ' package:flutter_hbb/desktop/widgets/tabbar_widget.dart ' ;
2022-08-17 16:28:36 +03:00
import ' package:flutter_hbb/main.dart ' ;
2022-09-13 16:38:47 +03:00
import ' package:flutter_hbb/models/server_model.dart ' ;
2022-10-20 17:05:34 +03:00
import ' package:flutter_localizations/flutter_localizations.dart ' ;
2022-08-17 16:28:36 +03:00
import ' package:get/get.dart ' ;
import ' package:window_manager/window_manager.dart ' ;
2022-10-20 17:05:34 +03:00
final testClients = [
Client ( 0 , false , false , " UserAAAAAA " , " 123123123 " , true , false , false ) ,
Client ( 1 , false , false , " UserBBBBB " , " 221123123 " , true , false , false ) ,
Client ( 2 , false , false , " UserC " , " 331123123 " , true , false , false ) ,
Client ( 3 , false , false , " UserDDDDDDDDDDDd " , " 441123123 " , true , false , false )
] ;
2023-09-28 04:05:10 +03:00
/// flutter run -d {platform} -t test/cm_test.dart to test cm
2022-08-17 16:28:36 +03:00
void main ( List < String > args ) async {
2022-10-20 17:05:34 +03:00
isTest = true ;
2022-08-17 16:28:36 +03:00
WidgetsFlutterBinding . ensureInitialized ( ) ;
await windowManager . ensureInitialized ( ) ;
2022-09-13 16:38:47 +03:00
await windowManager . setSize ( const Size ( 400 , 600 ) ) ;
2022-08-17 16:28:36 +03:00
await windowManager . setAlignment ( Alignment . topRight ) ;
2022-08-23 10:24:04 +03:00
await initEnv ( kAppTypeMain ) ;
2022-10-20 17:05:34 +03:00
for ( var client in testClients ) {
gFFI . serverModel . clients . add ( client ) ;
2022-10-26 17:50:36 +03:00
gFFI . serverModel . tabController . add ( TabInfo (
key: client . id . toString ( ) ,
label: client . name ,
closable: false ,
page: buildConnectionCard ( client ) ) ) ;
2022-10-20 17:05:34 +03:00
}
runApp ( GetMaterialApp (
debugShowCheckedModeBanner: false ,
theme: MyTheme . lightTheme ,
darkTheme: MyTheme . darkTheme ,
themeMode: MyTheme . currentThemeMode ( ) ,
localizationsDelegates: const [
GlobalMaterialLocalizations . delegate ,
GlobalWidgetsLocalizations . delegate ,
GlobalCupertinoLocalizations . delegate ,
] ,
supportedLocales: supportedLocales ,
home: const DesktopServerPage ( ) ) ) ;
2023-05-18 12:41:16 +03:00
WindowOptions windowOptions = getHiddenTitleBarWindowOptions (
size: kConnectionManagerWindowSizeClosedChat ) ;
2022-10-20 17:05:34 +03:00
windowManager . waitUntilReadyToShow ( windowOptions , ( ) async {
await windowManager . show ( ) ;
// ensure initial window size to be changed
2023-05-18 12:41:16 +03:00
await windowManager . setSize ( kConnectionManagerWindowSizeClosedChat ) ;
2022-10-20 17:05:34 +03:00
await Future . wait ( [
windowManager . setAlignment ( Alignment . topRight ) ,
windowManager . focus ( ) ,
windowManager . setOpacity ( 1 )
] ) ;
// ensure
windowManager . setAlignment ( Alignment . topRight ) ;
} ) ;
2022-08-17 16:28:36 +03:00
}