diff --git a/Sources/dafl_project_flutter/android/app/build.gradle b/Sources/dafl_project_flutter/android/app/build.gradle index 2fa22ec..97ae6a4 100644 --- a/Sources/dafl_project_flutter/android/app/build.gradle +++ b/Sources/dafl_project_flutter/android/app/build.gradle @@ -26,7 +26,8 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion flutter.compileSdkVersion + //compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 32 ndkVersion flutter.ndkVersion compileOptions { @@ -47,7 +48,8 @@ android { applicationId "com.example.dafl_project_flutter" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. - minSdkVersion flutter.minSdkVersion + //minSdkVersion flutter.minSdkVersion + minSdkVersion 17 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/Sources/dafl_project_flutter/android/app/src/main/AndroidManifest.xml b/Sources/dafl_project_flutter/android/app/src/main/AndroidManifest.xml index ad72fd6..9b5ec5f 100644 --- a/Sources/dafl_project_flutter/android/app/src/main/AndroidManifest.xml +++ b/Sources/dafl_project_flutter/android/app/src/main/AndroidManifest.xml @@ -25,17 +25,7 @@ - - - - - - - - + diff --git a/Sources/dafl_project_flutter/lib/spotify_api/.gitkeep b/Sources/dafl_project_flutter/lib/api/.gitkeep similarity index 100% rename from Sources/dafl_project_flutter/lib/spotify_api/.gitkeep rename to Sources/dafl_project_flutter/lib/api/.gitkeep diff --git a/Sources/dafl_project_flutter/lib/spotify_api/api.dart b/Sources/dafl_project_flutter/lib/api/api.dart similarity index 59% rename from Sources/dafl_project_flutter/lib/spotify_api/api.dart rename to Sources/dafl_project_flutter/lib/api/api.dart index 0e0936f..da39adf 100644 --- a/Sources/dafl_project_flutter/lib/spotify_api/api.dart +++ b/Sources/dafl_project_flutter/lib/api/api.dart @@ -1,17 +1,17 @@ -import 'package:url_launcher/url_launcher.dart'; import 'dart:math'; class Api { var clientId = '7ceb49d874b9404492246027e4d68cf8'; - var redirectUri = - 'https://codefirst.iut.uca.fr/containers/apiredirect-felixmielcarek/callback/'; + var redirectUri = 'https://daflmusic.000webhostapp.com/callback/'; var state; var scopes = 'user-read-private'; var url; + var code; + Api() { state = generateRandomString(); - url = Uri.https('accounts.spotify.com', 'en/authorize', { + url = Uri.https('accounts.spotify.com', 'authorize', { 'client_id': clientId, 'response_type': 'code', 'redirect_uri': redirectUri, @@ -21,15 +21,14 @@ class Api { }); } - Future launchInBrowser() async { - if (!await launchUrl( - url, - mode: LaunchMode.inAppWebView, - )) { - throw 'Could not launch $url'; + verifyLogIn(Uri url) { + if (verifyState(url.queryParameters['state'])) { + code = url.queryParameters['code']; } } + bool verifyState(String? newState) => state == newState; + // for state value String generateRandomString() { var r = Random(); diff --git a/Sources/dafl_project_flutter/lib/api/w_in_app_browser.dart b/Sources/dafl_project_flutter/lib/api/w_in_app_browser.dart new file mode 100644 index 0000000..9a76215 --- /dev/null +++ b/Sources/dafl_project_flutter/lib/api/w_in_app_browser.dart @@ -0,0 +1,52 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import './api.dart'; + +class MyInAppBrowser extends InAppBrowser { + var options = InAppBrowserClassOptions( + crossPlatform: + InAppBrowserOptions(hideUrlBar: true, hideToolbarTop: true), + inAppWebViewGroupOptions: InAppWebViewGroupOptions( + crossPlatform: InAppWebViewOptions(javaScriptEnabled: true))); + + Api api; + + MyInAppBrowser(this.api) { + _debugBrowser(); + launchBrowser(); + } + + _debugBrowser() async { + if (Platform.isAndroid) { + await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); + } + } + + launchBrowser() { + openUrlRequest(urlRequest: URLRequest(url: api.url), options: options); + } + + @override + Future onBrowserCreated() async {} + + @override + Future onLoadStart(url) async { + if (url!.origin + url!.path == api.redirectUri) { + api.verifyLogIn(url); + } + close(); + } + + @override + Future onLoadStop(url) async {} + + @override + void onLoadError(url, code, message) {} + + @override + void onProgressChanged(progress) {} + + @override + void onExit() {} +} diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 68fd00c..f88c899 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'package:dafl_project_flutter/views/pages/main/w_bottomsheet.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:vibration/vibration.dart'; import 'dart:math'; diff --git a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart index 8c017be..5cf07cb 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart @@ -1,10 +1,13 @@ -import 'package:dafl_project_flutter/spotify_api/api.dart'; +import 'package:dafl_project_flutter/api/api.dart'; import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; +import '../../../api/w_in_app_browser.dart'; import '../home/p_home.dart'; import '../sign_in/p_sign_in.dart'; class SignUpPage extends StatefulWidget { + static Api api = Api(); + const SignUpPage({Key? key}) : super(key: key); @override @@ -16,8 +19,7 @@ class _SignUpPageState extends State { bool isHovering = false; TextEditingController passwordconfirm = TextEditingController(); bool isChecked = false; - Api apiSptfy = Api(); - Future? _launched; + @override Widget build(BuildContext context) { double width = MediaQuery.of(context).size.width; @@ -215,19 +217,19 @@ class _SignUpPageState extends State { width: width * 0.75, child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF24CF5F), + backgroundColor: const Color(0xFF24CF5F), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100), ), // background// foreground ), - onPressed: () => setState(() { - _launched = apiSptfy.launchInBrowser(); - }), + onPressed: () { + MyInAppBrowser(SignUpPage.api); + }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - "Lier compte ", + const Text( + "Lier compte", style: TextStyle( fontFamily: 'DMSans', color: Colors.white, @@ -268,14 +270,6 @@ class _SignUpPageState extends State { ); }, child: Ink( - child: Align( - alignment: Alignment.center, - child: Icon( - Icons.check, - color: Color(0xFF406DE1), - size: 60.0, - ), - ), padding: const EdgeInsets.fromLTRB(0, 10, 0, 0), width: 83, height: 83, @@ -291,6 +285,14 @@ class _SignUpPageState extends State { ), ], ), + child: const Align( + alignment: Alignment.center, + child: Icon( + Icons.check, + color: Color(0xFF406DE1), + size: 60.0, + ), + ), ), ), ), diff --git a/Sources/dafl_project_flutter/linux/flutter/generated_plugin_registrant.cc b/Sources/dafl_project_flutter/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..e71a16d --- /dev/null +++ b/Sources/dafl_project_flutter/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/Sources/dafl_project_flutter/linux/flutter/generated_plugin_registrant.h b/Sources/dafl_project_flutter/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/Sources/dafl_project_flutter/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/Sources/dafl_project_flutter/linux/flutter/generated_plugins.cmake b/Sources/dafl_project_flutter/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..2e1de87 --- /dev/null +++ b/Sources/dafl_project_flutter/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/Sources/dafl_project_flutter/macos/Flutter/GeneratedPluginRegistrant.swift b/Sources/dafl_project_flutter/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..cccf817 --- /dev/null +++ b/Sources/dafl_project_flutter/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/Sources/dafl_project_flutter/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/Sources/dafl_project_flutter/macos/Flutter/ephemeral/Flutter-Generated.xcconfig new file mode 100644 index 0000000..1cd02d3 --- /dev/null +++ b/Sources/dafl_project_flutter/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -0,0 +1,11 @@ +// This is a generated file; do not edit or check into version control. +FLUTTER_ROOT=C:\flutter +FLUTTER_APPLICATION_PATH=C:\Users\Carbide\Documents\SAE\Sources\dafl_project_flutter +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=1.0.0 +FLUTTER_BUILD_NUMBER=1 +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/Sources/dafl_project_flutter/macos/Flutter/ephemeral/flutter_export_environment.sh b/Sources/dafl_project_flutter/macos/Flutter/ephemeral/flutter_export_environment.sh new file mode 100644 index 0000000..9f8e898 --- /dev/null +++ b/Sources/dafl_project_flutter/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\flutter" +export "FLUTTER_APPLICATION_PATH=C:\Users\Carbide\Documents\SAE\Sources\dafl_project_flutter" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/Sources/dafl_project_flutter/pubspec.lock b/Sources/dafl_project_flutter/pubspec.lock index 21e6fe9..2c97b71 100644 --- a/Sources/dafl_project_flutter/pubspec.lock +++ b/Sources/dafl_project_flutter/pubspec.lock @@ -104,6 +104,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_inappwebview: + dependency: "direct main" + description: + name: flutter_inappwebview + url: "https://pub.dartlang.org" + source: hosted + version: "5.7.1" flutter_launcher_icons: dependency: "direct dev" description: @@ -254,13 +261,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.0.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" provider: dependency: "direct main" description: @@ -329,27 +329,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.1" - uni_links: - dependency: "direct main" - description: - name: uni_links - url: "https://pub.dartlang.org" - source: hosted - version: "0.5.1" - uni_links_platform_interface: - dependency: transitive - description: - name: uni_links_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - uni_links_web: - dependency: transitive - description: - name: uni_links_web - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.0" universal_io: dependency: transitive description: @@ -357,62 +336,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.4" - url_launcher: - dependency: "direct main" - description: - name: url_launcher - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.6" - url_launcher_android: - dependency: transitive - description: - name: url_launcher_android - url: "https://pub.dartlang.org" - source: hosted - version: "6.0.19" - url_launcher_ios: - dependency: transitive - description: - name: url_launcher_ios - url: "https://pub.dartlang.org" - source: hosted - version: "6.0.17" - url_launcher_linux: - dependency: transitive - description: - name: url_launcher_linux - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - url_launcher_macos: - dependency: transitive - description: - name: url_launcher_macos - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - url_launcher_platform_interface: - dependency: transitive - description: - name: url_launcher_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - url_launcher_web: - dependency: transitive - description: - name: url_launcher_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - url_launcher_windows: - dependency: transitive - description: - name: url_launcher_windows - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" vector_math: dependency: transitive description: diff --git a/Sources/dafl_project_flutter/pubspec.yaml b/Sources/dafl_project_flutter/pubspec.yaml index 2350aec..8298131 100644 --- a/Sources/dafl_project_flutter/pubspec.yaml +++ b/Sources/dafl_project_flutter/pubspec.yaml @@ -1,40 +1,17 @@ name: dafl_project_flutter description: A new Flutter project. -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: 'none' -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 environment: sdk: '>=2.18.2 <3.0.0' -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 page_transition: ^2.0.9 provider: ^6.0.4 @@ -42,19 +19,13 @@ dependencies: rive: ^0.9.1 animations: ^2.0.7 fluttertoast: ^8.1.1 - url_launcher: ^6.1.6 - uni_links: ^0.5.1 vibration: ^1.7.6 + flutter_inappwebview: ^5.7.1 dev_dependencies: flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^2.0.0 flutter_launcher_icons: ^0.10.0 flutter_native_splash: ^2.2.11 @@ -68,39 +39,17 @@ flutter_native_splash: #background_image: "assets/images/background_blur.png" image: "assets/images/Logo_launcher_2.png" -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. - flutter_icons: android: true ios: true image_path: "assets/images/Logo_launcher_2.png" flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add assets to your application, add an assets section, like this: assets: - assets/images/ - assets/fonts/ - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: fonts: - family: DMSans fonts: @@ -118,5 +67,3 @@ flutter: - family: CustomIcons fonts: - asset: assets/fonts/CustomIcons.ttf - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages