diff --git a/Jenkinsfile b/Jenkinsfile index d90833a..1dbc985 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,6 @@ pipeline { string(name: 'APP_PACKAGE_ID', defaultValue: 'comptaplan.app', description: 'Application package id used as android identifier') string(name: 'APP_BUNDLE_ID', defaultValue: 'comptaplan_app', description: 'Application bundle id used as ios identifier') string(name: 'APP_TITLE', defaultValue: 'My Comptaplan', description: 'Application title') - string(name: 'APP_URI', defaultValue: 'https://my.comptaplan.be', description: 'Application uri') string(name: 'APP_COLOR', defaultValue: 'blue', description: 'Application color (blue, teal, ...)') string(name: 'BUILD_MODE', defaultValue: 'debug', description: 'Flutter build mode (debug/release)') string(name: 'ANDROID_SIGNING_KEYSTORE_CREDENTIAL', defaultValue: 'jenkins-gestemps-android-service-secret-keystore') @@ -39,7 +38,6 @@ pipeline { env.APP_PACKAGE_ID= params.APP_PACKAGE_ID env.APP_BUNDLE_ID= params.APP_BUNDLE_ID env.APP_TITLE= params.APP_TITLE - env.APP_URI= params.APP_URI env.APP_COLOR= params.APP_COLOR env.BUILD_MODE= params.BUILD_MODE env.SSH_KNOWN_HOSTS_FILE= params.SSH_KNOWN_HOSTS_FILE diff --git a/images/winbooks_connect.png b/images/winbooks_connect.png new file mode 100644 index 0000000..e280904 Binary files /dev/null and b/images/winbooks_connect.png differ diff --git a/lib/main.dart b/lib/main.dart index d087092..f666b70 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,11 +1,11 @@ -import 'package:comptaplan_app/webview_widget.dart'; +import 'package:comptaplan_app/winbooks_migration_widget.dart'; import 'package:flutter/material.dart'; void main() { const title = String.fromEnvironment("APP_TITLE"); - const uri = String.fromEnvironment("APP_URI"); + const playStoreUri = 'https://play.google.com/store/apps/details?id=com.winbooks.connect'; const color = String.fromEnvironment("APP_COLOR"); - runApp(const MyApp(title, uri, color)); + runApp(const MyApp(title, playStoreUri, color)); } class MyApp extends StatelessWidget { @@ -19,7 +19,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { MaterialColor materialColor = _getMaterialColor(_color); - return MaterialApp(title: _title, theme: ThemeData(primarySwatch: materialColor), home: WebViewWidget(_uri)); + return MaterialApp(title: _title, theme: ThemeData(primarySwatch: materialColor), home: WinbooksMigrationWidget(_title, _uri)); } MaterialColor _getMaterialColor(String colorString) { diff --git a/lib/webview_widget.dart b/lib/webview_widget.dart deleted file mode 100644 index a16e0c1..0000000 --- a/lib/webview_widget.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:flutter_webview_pro/webview_flutter.dart'; - -class WebViewWidget extends StatefulWidget { - final String _initialUrl; - - const WebViewWidget(this._initialUrl, {Key? key}) : super(key: key); - - @override - WebViewWidgetState createState() => WebViewWidgetState(); -} - -class WebViewWidgetState extends State { - WebViewWidgetState(); - - @override - void initState() { - super.initState(); - // Enable hybrid composition. - if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); - } - - @override - Widget build(BuildContext context) { - return WebView( - initialUrl: widget._initialUrl, - javascriptMode: JavascriptMode.unrestricted, - javascriptChannels: { - _toasterJavascriptChannel(context), - }, - gestureNavigationEnabled: true, - ); - } - - JavascriptChannel _toasterJavascriptChannel(BuildContext context) { - return JavascriptChannel( - name: 'Toaster', - onMessageReceived: (JavascriptMessage message) { - // ignore: deprecated_member_use - Scaffold.of(context).showSnackBar( - SnackBar(content: Text(message.message)), - ); - }); - } -} diff --git a/lib/winbooks_migration_widget.dart b/lib/winbooks_migration_widget.dart new file mode 100644 index 0000000..0dafbfb --- /dev/null +++ b/lib/winbooks_migration_widget.dart @@ -0,0 +1,83 @@ +import 'dart:io'; + +import 'package:android_intent_plus/android_intent.dart'; +import 'package:flutter/material.dart'; + +class WinbooksMigrationWidget extends StatefulWidget { + final String _playStoreUrl; + final String _title; + + const WinbooksMigrationWidget(this._title, this._playStoreUrl, {Key? key}) : super(key: key); + + @override + WinbooksMigrationWidgetState createState() => WinbooksMigrationWidgetState(); +} + +class WinbooksMigrationWidgetState extends State { + WinbooksMigrationWidgetState(); + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + ThemeData themeData = Theme.of(context); + TextStyle largerTextStyle = themeData.textTheme.bodyText1!.apply(fontSizeFactor: 1.4); + TextStyle smallerTextStyle = themeData.textTheme.bodyText2!; + AssetBundle assetBundle = DefaultAssetBundle.of(context); + return Scaffold( + appBar: AppBar( + title: Text(widget._title), + ), + body: GridView.count( + crossAxisCount: 1, + children: [ + Column(children: [ + Container( + margin: const EdgeInsets.all(10.0), + child: Text( + 'My comptaplan migre vers WinBooks Connect. Téléchargez WinBooks Connect pour continuer à envoyer vos fichiers à votre comptable', + textAlign: TextAlign.center, + style: largerTextStyle), + ), + Center( + child: Container( + margin: const EdgeInsets.all(10.0), + child: ElevatedButton( + style: ElevatedButton.styleFrom(textStyle: largerTextStyle, padding: const EdgeInsets.all(20.0)), + child: Row(children: [ + Image.asset('images/winbooks_connect.png', bundle: assetBundle, width: 50.0, height: 50.0), + const SizedBox(width: 10), + const Text('Télécharger WinBooks Connect') + ]), + onPressed: () async { + return _onWinbooksConnectPress(); + }, + ), + ), + ), + Container( + margin: const EdgeInsets.all(10.0), + child: Text( + 'Si vous ne parvenez pas à télécharger Winbooks Connect, ou pour obtenir vos identifiants, veuillez contacter votre comptable.', + textAlign: TextAlign.left, + style: smallerTextStyle), + ), + ]) + ], + )); + } + + Future _onWinbooksConnectPress() async { + if (Platform.isAndroid) { + AndroidIntent intent = AndroidIntent( + action: 'action_view', + data: widget._playStoreUrl, + package: 'com.android.vending', + ); + return intent.launch(); + } + } +} diff --git a/pubspec.lock b/pubspec.lock index f1e5d5e..102305b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,13 +1,20 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + android_intent_plus: + dependency: "direct main" + description: + name: android_intent_plus + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -21,7 +28,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: @@ -94,7 +101,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: transitive description: @@ -109,6 +116,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" sky_engine: dependency: transitive description: flutter @@ -155,7 +169,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.3" typed_data: dependency: transitive description: @@ -169,7 +183,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.14.0 <3.0.0" flutter: ">=1.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 62315b0..1abf7f2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: cupertino_icons: ^1.0.2 #webview_flutter: ^2.3.1 flutter_webview_pro: ^1.0.0 + android_intent_plus: ^3.0.2 dev_dependencies: flutter_test: @@ -60,8 +61,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg + assets: + - images/winbooks_connect.png # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see