Link between front-end and back-end

This commit is contained in:
2025-07-09 12:41:00 +02:00
parent 6735ddb5fd
commit 1b261c08bb
31 changed files with 5507 additions and 40 deletions

View File

@ -1,38 +1,229 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:logging/logging.dart';
import 'package:rtime/db/db_helper.dart';
import 'package:rtime/images_manager.dart';
import 'package:rtime/models/drone.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart';
import 'package:rtime/l10n/app_localizations.dart';
import 'package:rtime/pages/home_page.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:image_picker/image_picker.dart';
import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart';
import 'package:rtime/providers/local_provider.dart';
import 'package:rtime/providers/theme_provider.dart';
void main() {
if (Platform.isWindows || Platform.isLinux) {
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
}
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen(
(record) =>
print('${record.level.name}: ${record.time}: ${record.message}'),
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => LocaleProvider(),
),
ChangeNotifierProvider(
create: (context) => ThemeProvider(),
),
],
child: const MyApp(),
),
);
runApp(const RTimeApp());
//DbHelper.instance.closeDb();
}
class RTimeApp extends StatelessWidget {
const RTimeApp({super.key});
class MyApp extends StatefulWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Text("RtimeAPP");
}
return Consumer2<LocaleProvider, ThemeProvider>(
builder: (context, localeProvider, themeProvider, child) {
return MaterialApp(
title: 'Rtime',
locale: localeProvider.locale,
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en', ''),
Locale('fr', ''),
],
theme: ThemeData(
primaryColor: Colors.white,
colorScheme: ColorScheme.light(
primary: Colors.blue.shade600,
secondary: Colors.teal.shade400,
surface: Colors.white,
background: Colors.white,
error: Colors.red.shade700,
onPrimary: Colors.white,
onSecondary: Colors.white,
onSurface: Colors.black87,
onBackground: Colors.black87,
),
scaffoldBackgroundColor: Colors.white,
appBarTheme: AppBarTheme(
backgroundColor: Colors.white,
foregroundColor: Colors.black87,
elevation: 0.5,
iconTheme: const IconThemeData(color: Colors.black87),
titleTextStyle: const TextStyle(
color: Colors.black87,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
floatingActionButtonTheme: FloatingActionButtonThemeData(
backgroundColor: Colors.blue.shade600,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
extendedSizeConstraints: const BoxConstraints.tightFor(
height: 70.0,
width: 250.0,
),
),
cardTheme: CardThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 2,
color: Colors.white,
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
listTileTheme: ListTileThemeData(
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
tileColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
selectedTileColor: Colors.blue.shade50,
),
textTheme: const TextTheme(
headlineSmall: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87),
titleMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.black87),
titleSmall: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.black54),
bodyLarge: TextStyle(color: Colors.black87),
bodyMedium: TextStyle(color: Colors.black54),
bodySmall: TextStyle(fontSize: 12, color: Colors.black45),
),
visualDensity: VisualDensity.adaptivePlatformDensity,
buttonTheme: ButtonThemeData(
buttonColor: Colors.blue.shade600,
textTheme: ButtonTextTheme.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: Colors.grey.shade400),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: Colors.blue.shade600, width: 2),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: Colors.grey.shade300),
),
labelStyle: const TextStyle(color: Colors.black54),
hintStyle: TextStyle(color: Colors.grey.shade500),
),
),
darkTheme: ThemeData.dark().copyWith(
primaryColor: Colors.blueGrey[900],
colorScheme: ColorScheme.dark(
primary: Colors.lightBlueAccent,
secondary: Colors.tealAccent,
surface: Colors.blueGrey.shade800,
background: Colors.blueGrey.shade900,
onPrimary: Colors.black,
onSecondary: Colors.black,
onSurface: Colors.white,
onBackground: Colors.white,
),
appBarTheme: AppBarTheme(
backgroundColor: Colors.blueGrey[900],
foregroundColor: Colors.white,
elevation: 4,
iconTheme: const IconThemeData(color: Colors.white),
titleTextStyle: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
floatingActionButtonTheme: FloatingActionButtonThemeData(
backgroundColor: Colors.lightBlueAccent,
foregroundColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
extendedSizeConstraints: const BoxConstraints.tightFor(
height: 70.0,
width: 250.0,
),
),
cardTheme: CardThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 8,
color: Colors.blueGrey[800],
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
listTileTheme: ListTileThemeData(
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
tileColor: Colors.blueGrey[800],
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
selectedTileColor: Colors.blueGrey[700],
),
textTheme: const TextTheme(
headlineSmall: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.white),
titleMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white),
titleSmall: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
bodyLarge: TextStyle(color: Colors.white70),
bodyMedium: TextStyle(color: Colors.white60),
bodySmall: TextStyle(fontSize: 12, color: Colors.white70),
),
visualDensity: VisualDensity.adaptivePlatformDensity,
buttonTheme: ButtonThemeData(
buttonColor: Colors.lightBlueAccent,
textTheme: ButtonTextTheme.primary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: Colors.blueGrey.shade600),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: Colors.lightBlueAccent, width: 2),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: Colors.blueGrey.shade700),
),
labelStyle: const TextStyle(color: Colors.white70),
hintStyle: TextStyle(color: Colors.blueGrey.shade500),
),
),
themeMode: themeProvider.themeMode,
home: const HomePage(),
);
},
);
}
}