diff --git a/android/gradle.properties b/android/gradle.properties index 597f90128b8843068fe1d70a72b1bd9bcd1c908b..3e4ee4f7fc752c7bb9d11bf7ffc76f46dd8039d7 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=1.0.20 -app.versionCode=21 +app.versionName=1.0.21 +app.versionCode=22 diff --git a/assets/translations/en.json b/assets/translations/en.json new file mode 100644 index 0000000000000000000000000000000000000000..f5e702ddc07406ea3f4ac0f7713b58bcf238b344 --- /dev/null +++ b/assets/translations/en.json @@ -0,0 +1,6 @@ +{ + "app_name": "Random application", + + "TOP": "TOP", + "BOTTOM": "BOTTOM" +} diff --git a/assets/translations/fr.json b/assets/translations/fr.json new file mode 100644 index 0000000000000000000000000000000000000000..1b75c0926fdd377711092fdc992a54b143e2af2b --- /dev/null +++ b/assets/translations/fr.json @@ -0,0 +1,6 @@ +{ + "app_name": "Random application", + + "TOP": "HAUT", + "BOTTOM": "BAS" +} diff --git a/lib/activities/ActivityDemoPage.dart b/lib/activities/ActivityDemoPage.dart index a3ad6c1b7c1752112eba20ce8e40bfee21316bfb..cbe5ff79e5f7e990d70034e6e5b0c19785513a9b 100644 --- a/lib/activities/ActivityDemoPage.dart +++ b/lib/activities/ActivityDemoPage.dart @@ -1,6 +1,5 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:random/provider/data.dart'; class ActivityDemoPage extends StatelessWidget { static const String code = 'demo'; @@ -8,8 +7,6 @@ class ActivityDemoPage extends StatelessWidget { @override Widget build(BuildContext context) { - Data myProvider = Provider.of<Data>(context); - Scaffold pageContent = Scaffold( appBar: AppBar( elevation: 0, @@ -17,7 +14,7 @@ class ActivityDemoPage extends StatelessWidget { IconButton( icon: const Icon(Icons.arrow_back), onPressed: () { - myProvider.resetActivity(); + print('reset activity'); Navigator.pop(context); }, ), @@ -30,9 +27,9 @@ class ActivityDemoPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: <Widget>[ - Text('TOP'), + Text('TOP').tr(), SizedBox(height: 2), - Text('BOTTOM'), + Text('BOTTOM').tr(), ], ), ), diff --git a/lib/activities/ActivityGraphPage.dart b/lib/activities/ActivityGraphPage.dart index bb2fed8bad658c3f44f2372d837d09123e5f946b..7fa2cbae14ca103b5b265ae37a44577cc9ddf9e0 100644 --- a/lib/activities/ActivityGraphPage.dart +++ b/lib/activities/ActivityGraphPage.dart @@ -1,16 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:random/painters/GraphPainter.dart'; -import 'package:random/provider/data.dart'; - class ActivityGraphPage extends StatelessWidget { static const String code = 'graph'; static const String route = '/' + code; @override Widget build(BuildContext context) { - Data myProvider = Provider.of<Data>(context); double boardWidth = MediaQuery.of(context).size.width; Scaffold pageContent = Scaffold( @@ -20,7 +16,7 @@ class ActivityGraphPage extends StatelessWidget { IconButton( icon: const Icon(Icons.arrow_back), onPressed: () { - myProvider.resetActivity(); + print('reset activity'); Navigator.pop(context); }, ), @@ -45,7 +41,7 @@ class ActivityGraphPage extends StatelessWidget { child: CustomPaint( size: Size(boardWidth, boardWidth), willChange: false, - painter: GraphPainter(myProvider), + painter: GraphPainter(), isComplex: true, ), ), diff --git a/lib/main.dart b/lib/main.dart index 3dc7b4d92eb733a3340315394dff6910fe5a3584..0add32855ed05690b9510934e5a108a96884e1ce 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,56 +1,69 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:provider/provider.dart'; -import 'package:random/provider/data.dart'; import 'package:random/activities/ActivityDemoPage.dart'; import 'package:random/activities/ActivityGraphPage.dart'; import 'package:random/screens/home.dart'; -void main() { +void main() async { WidgetsFlutterBinding.ensureInitialized(); - SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) - .then((value) => runApp(MyApp())); + await EasyLocalization.ensureInitialized(); + + runApp( + EasyLocalization( + path: 'assets/translations', + supportedLocales: const <Locale>[ + Locale('en'), + Locale('fr'), + ], + fallbackLocale: const Locale('en'), + useFallbackTranslations: true, + child: const MyApp(), + ), + ); } class MyApp extends StatelessWidget { + const MyApp({super.key}); + @override Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (BuildContext context) => Data(), - child: Consumer<Data>(builder: (context, data, child) { - return MaterialApp( - title: 'Random application - testing stuff...', - theme: ThemeData( - primarySwatch: Colors.blue, - ), - home: Home(), - onGenerateRoute: (settings) { - switch (settings.name) { - case ActivityDemoPage.route: - { - return MaterialPageRoute( - builder: (context) => ActivityDemoPage(), - ); - } - case ActivityGraphPage.route: - { - return MaterialPageRoute( - builder: (context) => ActivityGraphPage(), - ); - } - - default: - { - print("Unknown menu entry: " + settings.name.toString()); - } - break; + return MaterialApp( + title: 'Random application', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: Home(), + onGenerateRoute: (settings) { + switch (settings.name) { + case ActivityDemoPage.route: + { + return MaterialPageRoute( + builder: (context) => ActivityDemoPage(), + ); + } + case ActivityGraphPage.route: + { + return MaterialPageRoute( + builder: (context) => ActivityGraphPage(), + ); } - return null; - }, - ); - }), + default: + { + print("Unknown menu entry: " + settings.name.toString()); + } + break; + } + + return null; + }, + + // Localization stuff + localizationsDelegates: context.localizationDelegates, + supportedLocales: context.supportedLocales, + locale: context.locale, + debugShowCheckedModeBanner: false, ); } } diff --git a/lib/painters/GraphPainter.dart b/lib/painters/GraphPainter.dart index 38c12994462fd13de15529a993bf6adbcba5ff91..a088d81f45a9a94d18e48770cf44b02a44db919a 100644 --- a/lib/painters/GraphPainter.dart +++ b/lib/painters/GraphPainter.dart @@ -1,12 +1,8 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:random/provider/data.dart'; - class GraphPainter extends CustomPainter { - const GraphPainter(this.myProvider); - - final Data myProvider; + const GraphPainter(); double random(double max) { return Random().nextDouble() * max; diff --git a/lib/provider/data.dart b/lib/provider/data.dart deleted file mode 100644 index 4859c99000e698830f656dce26ba2922cbef0cb0..0000000000000000000000000000000000000000 --- a/lib/provider/data.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:flutter/foundation.dart'; - -class Data extends ChangeNotifier { - void resetActivity() { - print('reset activity'); - } -} diff --git a/pubspec.lock b/pubspec.lock index d6c8af1258d48abed9fd1fa0287e7098c886d2fc..307e7a3551b7bb03020b135cef2c6e8494646455 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" characters: dependency: transitive description: @@ -9,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" collection: dependency: transitive description: @@ -17,11 +33,61 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.2" + easy_localization: + dependency: "direct main" + description: + name: easy_localization + sha256: de63e3b422adfc97f256cbb3f8cf12739b6a4993d390f3cadb3f51837afaefe5 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + easy_logger: + dependency: transitive + description: + name: easy_logger + sha256: c764a6e024846f33405a2342caf91c62e357c24b02c04dbc712ef232bf30ffb7 + url: "https://pub.dev" + source: hosted + version: "0.0.2" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + intl: + dependency: transitive + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" material_color_utilities: dependency: transitive description: @@ -38,22 +104,110 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - nested: + path: dependency: transitive description: - name: nested - sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.0.0" - provider: - dependency: "direct main" + version: "1.8.3" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + platform: + dependency: transitive + description: + name: platform + sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59" + url: "https://pub.dev" + source: hosted + version: "3.1.3" + plugin_platform_interface: + dependency: transitive description: - name: provider - sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + name: plugin_platform_interface + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d url: "https://pub.dev" source: hosted - version: "6.0.5" + version: "2.1.6" + shared_preferences: + dependency: transitive + description: + name: shared_preferences + sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7" + url: "https://pub.dev" + source: hosted + version: "2.3.4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a + url: "https://pub.dev" + source: hosted + version: "2.3.1" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf + url: "https://pub.dev" + source: hosted + version: "2.2.1" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" + url: "https://pub.dev" + source: hosted + version: "2.3.2" sky_engine: dependency: transitive description: flutter @@ -75,6 +229,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.4-beta" + win32: + dependency: transitive + description: + name: win32 + sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3" + url: "https://pub.dev" + source: hosted + version: "5.0.9" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2" + url: "https://pub.dev" + source: hosted + version: "1.0.3" sdks: dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=1.16.0" + flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index b264b8f223b1e7b15d78e85fb263dce9488165c2..1385047fef4349e1c102eb1e6250868059a58625 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,9 @@ name: random -description: A random application. +description: A random application, for testing purpose only. + publish_to: 'none' -version: 1.0.0+1 + +version: 1.0.21+22 environment: sdk: '^3.0.0' @@ -9,9 +11,11 @@ environment: dependencies: flutter: sdk: flutter - provider: ^6.0.5 + + easy_localization: ^3.0.1 flutter: uses-material-design: true assets: - assets/menu/ + - assets/translations/