Removing useless binary in conf + managing services url resolution at runtime

This commit is contained in:
plm
2025-01-09 10:29:31 +01:00
parent 2c86e90b76
commit 047591d031
118 changed files with 1185 additions and 4699 deletions

View File

@@ -12,28 +12,38 @@ import 'package:oc_front/core/services/auth.service.dart';
import 'package:oc_front/core/services/router.dart';
import 'package:oc_front/core/sections/end_drawer.dart';
import 'package:oc_front/widgets/dialog/login.dart';
import 'package:oc_front/core/conf/conf_reader.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
WidgetsFlutterBinding.ensureInitialized();
// Load configuration before running the app
final appConfig = AppConfig();
await appConfig.loadConfig();
// Run `LinuxWebViewPlugin.initialize()` first before creating a WebView.
await initLocalStorage();
runApp(const MyApp());
}
GlobalKey<MainPageState>? mainKey;
GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
AuthService.init();
return MaterialApp.router( routerConfig: GoRouter( routes: AppRouter.routes ) );
return MaterialApp.router(routerConfig: GoRouter(routes: AppRouter.routes));
}
}
// ignore: must_be_immutable
class MainPage extends StatefulWidget {
Widget? page;
MainPage({Key? key, required this.page}) : super(key: GlobalKey<MainPageState>());
MainPage({Key? key, required this.page})
: super(key: GlobalKey<MainPageState>());
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
@@ -49,22 +59,27 @@ class MainPage extends StatefulWidget {
}
var darkColor = Color.fromRGBO(26, 83, 92, 1);
var lightColor = Color.fromRGBO(78, 205, 196, 1);
var lightColor = Color.fromRGBO(78, 205, 196, 1);
var darkMidColor = Color.fromRGBO(44, 83, 100, 1);
var midColor = Colors.grey.shade300;
var redColor = Color.fromRGBO(255, 107, 107, 1);
double getWidth(BuildContext context) {
return MediaQuery.of(context).size.width <= 800 ? 800 : MediaQuery.of(context).size.width;
return MediaQuery.of(context).size.width <= 800
? 800
: MediaQuery.of(context).size.width;
}
double getHeight(BuildContext context) {
return MediaQuery.of(context).size.height <= 400 ? 400 : MediaQuery.of(context).size.height;
return MediaQuery.of(context).size.height <= 400
? 400
: MediaQuery.of(context).size.height;
}
double getMainHeight(BuildContext context) {
return getHeight(context) - HeaderConstants.height;
}
double getMainWidth(BuildContext context) {
return getWidth(context) - 50;
}
@@ -88,63 +103,80 @@ class MainPageState extends State<MainPage> {
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.i
scaffoldKey = GlobalKey<ScaffoldState>();
isCtrl = false;
isCtrl = false;
if (!AuthService.isConnected()) {
print("isConnected: ${AuthService.isConnected()}");
Future.delayed(const Duration(milliseconds: 500), () {
showDialog(
barrierDismissible: false,
context: context, builder: (context) {
return AlertDialog(
print("isConnected: ${AuthService.isConnected()}");
Future.delayed(const Duration(milliseconds: 500), () {
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return AlertDialog(
insetPadding: EdgeInsets.zero,
backgroundColor: Colors.white,
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0)),
title: LoginWidget());
});
});
});
});
}
return FutureBuilder(future: AuthService.init(),
builder: (e, s) {
WorkspaceLocal.init(context, false);
CollaborativeAreaLocal.init(context, false);
HeaderConstants.height = HeaderConstants.isNoHeader(AppRouter.currentRoute.route) || AppRouter.currentRoute.factory.searchFill() ? 50 : 100;
return Scaffold( key: scaffoldKey, endDrawer: EndDrawerWidget(), body:
SingleChildScrollView(
controller: ScrollController(),
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
child: Column( children: [
HeaderMenuWidget(),
Row( children : [
Container( padding: const EdgeInsets.symmetric(vertical: 30),
decoration: BoxDecoration( color: darkColor),
width: 50, height: getHeight(context) - 50,
child: SingleChildScrollView( child: LeftMenuWidget() )),
SizedBox( width: getMainWidth(context), height: getHeight(context) - 50,
child: KeyboardListener(
focusNode: node,
onKeyEvent: (event) async {
if ( event.logicalKey == LogicalKeyboardKey.controlLeft ) {
isCtrl = (event is KeyDownEvent);
node.requestFocus();
} else if( (event is KeyDownEvent) && event.logicalKey == LogicalKeyboardKey.enter) {
AppRouter.currentRoute.factory.search(context, isCtrl);
node.requestFocus();
}
},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
HeaderWidget(),
widget.page ?? Container() // CatalogPageWidget(),
],
),
)),
])
])
)
));
});
return FutureBuilder(
future: AuthService.init(),
builder: (e, s) {
WorkspaceLocal.init(context, false);
CollaborativeAreaLocal.init(context, false);
HeaderConstants.height =
HeaderConstants.isNoHeader(AppRouter.currentRoute.route) ||
AppRouter.currentRoute.factory.searchFill()
? 50
: 100;
return Scaffold(
key: scaffoldKey,
endDrawer: EndDrawerWidget(),
body: SingleChildScrollView(
controller: ScrollController(),
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
child: Column(children: [
HeaderMenuWidget(),
Row(children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 30),
decoration: BoxDecoration(color: darkColor),
width: 50,
height: getHeight(context) - 50,
child:
SingleChildScrollView(child: LeftMenuWidget())),
SizedBox(
width: getMainWidth(context),
height: getHeight(context) - 50,
child: KeyboardListener(
focusNode: node,
onKeyEvent: (event) async {
if (event.logicalKey ==
LogicalKeyboardKey.controlLeft) {
isCtrl = (event is KeyDownEvent);
node.requestFocus();
} else if ((event is KeyDownEvent) &&
event.logicalKey ==
LogicalKeyboardKey.enter) {
AppRouter.currentRoute.factory
.search(context, isCtrl);
node.requestFocus();
}
},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
HeaderWidget(),
widget.page ??
Container() // CatalogPageWidget(),
],
),
)),
])
]))));
});
}
}