diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml new file mode 100644 index 0000000..b8ed782 --- /dev/null +++ b/.idea/libraries/Dart_Packages.xml @@ -0,0 +1,444 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 008f0f6..6ae284f 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Sources/dafl_project_flutter/.metadata b/Sources/dafl_project_flutter/.metadata index e1179a6..308a9a8 100644 --- a/Sources/dafl_project_flutter/.metadata +++ b/Sources/dafl_project_flutter/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled. version: - revision: 18a827f3933c19f51862dde3fa472197683249d6 + revision: eb6d86ee27deecba4a83536aa20f366a6044895c channel: stable project_type: app @@ -13,26 +13,14 @@ project_type: app migration: platforms: - platform: root - create_revision: 18a827f3933c19f51862dde3fa472197683249d6 - base_revision: 18a827f3933c19f51862dde3fa472197683249d6 + create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - platform: android - create_revision: 18a827f3933c19f51862dde3fa472197683249d6 - base_revision: 18a827f3933c19f51862dde3fa472197683249d6 + create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - platform: ios - create_revision: 18a827f3933c19f51862dde3fa472197683249d6 - base_revision: 18a827f3933c19f51862dde3fa472197683249d6 - - platform: linux - create_revision: 18a827f3933c19f51862dde3fa472197683249d6 - base_revision: 18a827f3933c19f51862dde3fa472197683249d6 - - platform: macos - create_revision: 18a827f3933c19f51862dde3fa472197683249d6 - base_revision: 18a827f3933c19f51862dde3fa472197683249d6 - - platform: web - create_revision: 18a827f3933c19f51862dde3fa472197683249d6 - base_revision: 18a827f3933c19f51862dde3fa472197683249d6 - - platform: windows - create_revision: 18a827f3933c19f51862dde3fa472197683249d6 - base_revision: 18a827f3933c19f51862dde3fa472197683249d6 + create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c # User provided section diff --git a/Sources/dafl_project_flutter/android/app/build.gradle b/Sources/dafl_project_flutter/android/app/build.gradle index fce04cc..97360f6 100644 --- a/Sources/dafl_project_flutter/android/app/build.gradle +++ b/Sources/dafl_project_flutter/android/app/build.gradle @@ -47,7 +47,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 ed40f7f..defab80 100644 --- a/Sources/dafl_project_flutter/android/app/src/main/AndroidManifest.xml +++ b/Sources/dafl_project_flutter/android/app/src/main/AndroidManifest.xml @@ -3,7 +3,7 @@ + + - + + + diff --git a/Sources/dafl_project_flutter/android/build.gradle b/Sources/dafl_project_flutter/android/build.gradle index 83ae220..4256f91 100644 --- a/Sources/dafl_project_flutter/android/build.gradle +++ b/Sources/dafl_project_flutter/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/Sources/dafl_project_flutter/android/gradle/wrapper/gradle-wrapper.properties b/Sources/dafl_project_flutter/android/gradle/wrapper/gradle-wrapper.properties index cb24abd..3c9d085 100644 --- a/Sources/dafl_project_flutter/android/gradle/wrapper/gradle-wrapper.properties +++ b/Sources/dafl_project_flutter/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/Sources/dafl_project_flutter/ios/Runner/Info.plist b/Sources/dafl_project_flutter/ios/Runner/Info.plist index 60521b9..fdf519a 100644 --- a/Sources/dafl_project_flutter/ios/Runner/Info.plist +++ b/Sources/dafl_project_flutter/ios/Runner/Info.plist @@ -13,7 +13,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - dafl_project_flutter + Dafl Music CFBundlePackageType APPL CFBundleShortVersionString 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/api/api.dart b/Sources/dafl_project_flutter/lib/api/api.dart new file mode 100644 index 0000000..982282c --- /dev/null +++ b/Sources/dafl_project_flutter/lib/api/api.dart @@ -0,0 +1,156 @@ +import 'dart:convert'; +import 'dart:math'; +import 'package:http/http.dart' as http; +import 'package:crypto/crypto.dart'; + +import 'track.dart'; + +class Api { + //from dashboard + final _clientId = '7ceb49d874b9404492246027e4d68cf8'; + final _clientSecret = '98f9cb960bf54ebbb9ad306e7ff919cb'; + + //for web api + get redirectUri => 'https://daflmusic.000webhostapp.com/callback/'; + final _scopes = 'user-read-playback-state user-read-currently-playing'; + late String _state; + dynamic _codeVerifier; + dynamic _codeChallenge; + late String _encodedLogs; + final _tokenType = 'Bearer '; + + //from web api + String? _code; + int? _expiresIn; + String? _refreshToken; + String? _accessToken; //use _getToken() as kind of a private getter + + //other + final _client = http.Client(); + late Uri _urlAuthorize; + + get urlAuthorize => _urlAuthorize; + DateTime? _tokenEnd; + + Api() { + _state = _generateRandomString(16); + _codeVerifier = _generateRandomString(_generateRandomInt(43, 128)); + _codeChallenge = _generateCodeChallenge(); + print(_codeChallenge); + _encodedLogs = base64.encode(utf8.encode("$_clientId:$_clientSecret")); + _urlAuthorize = Uri.https('accounts.spotify.com', 'authorize', { + 'client_id': _clientId, + 'response_type': 'code', + 'redirect_uri': redirectUri, + 'state': _state, + 'scope': _scopes, + 'show_dialog': 'false', + 'code_challenge_method': 'S256', + 'code_challenge': _codeChallenge + }); + } + + //PKCE generations + + _generateRandomInt(int min, int max) { + return min + Random().nextInt(max - min); + } + + _generateRandomString(int length) { + const chars = + 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890'; + return String.fromCharCodes(Iterable.generate( + length, (_) => chars.codeUnitAt(Random().nextInt(chars.length)))); + } + + _generateCodeChallenge() { + //care : base64Url doesn't work + return base64Encode(sha256.convert(utf8.encode(_codeVerifier)).bytes) + .replaceAll('+', '-') + .replaceAll('/', '_') + .replaceAll('=', ''); + } + + //session management + + requestUserAuthorization(Uri url) async { + if (url.queryParameters['state'] == _state.toString()) { + _code = url.queryParameters['code']; + await _requestAccessToken(); + } + // TODO : implement the else + } + + _requestAccessToken() async { + var urlToken = Uri.https('accounts.spotify.com', 'api/token', { + 'code': _code, + 'redirect_uri': redirectUri, + 'grant_type': 'authorization_code', + 'client_id': _clientId, + 'code_verifier': _codeVerifier + }); + var response = await _client.post(urlToken, headers: { + 'Authorization': 'Basic $_encodedLogs', + 'Content-Type': 'application/x-www-form-urlencoded' + }); + var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)) as Map; + _accessToken = decodedResponse['access_token']; + _expiresIn = decodedResponse['expires_in']; + _tokenEnd = DateTime.now().add(Duration(seconds: _expiresIn!)); + _refreshToken = decodedResponse['refresh_token']; + } + + Future _getToken() async { + await _tokenValidity(); + return _accessToken; + } + + _tokenValidity() async { + if (DateTime.now().isAfter(_tokenEnd!)) { + await _getRefreshedAccessToken(); + } + } + + _getRefreshedAccessToken() async { + var urlToken = Uri.https('accounts.spotify.com', 'api/token', { + 'grant_type': 'refresh_token', + 'refresh_token': _refreshToken, + 'client_id': _clientId + }); + var response = await _client.post(urlToken, headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }); + var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)) as Map; + _accessToken = decodedResponse['access_token']; + _expiresIn = decodedResponse['expires_in']; + _tokenEnd = DateTime.now().add(Duration(seconds: _expiresIn!)); + } + + //functional methods + + Future getCurrentlyPlayingTrack() async { + var url = Uri.https('api.spotify.com', 'v1/me/player/currently-playing'); + var token = await _getToken(); + var response = await _client.get(url, headers: { + 'Authorization': '$_tokenType $token', + 'Content-Type': 'application/json' + }); + var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)) as Map; + return decodedResponse['item']['id']; + } + + Future getTrackInfo(String id) async { + var url = Uri.https('api.spotify.com', 'v1/tracks/$id'); + var token = await _getToken(); + var response = await _client.get(url, headers: { + 'Authorization': '$_tokenType $token', + 'Content-Type': 'application/json' + }); + var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)) as Map; + return Track( + decodedResponse['artists'][0]['name'], + decodedResponse['name'], + decodedResponse['album']['images'] + [decodedResponse['album']['images'].length - 1]['url']); + } +} diff --git a/Sources/dafl_project_flutter/lib/api/in_app_browser.dart b/Sources/dafl_project_flutter/lib/api/in_app_browser.dart new file mode 100644 index 0000000..0424e86 --- /dev/null +++ b/Sources/dafl_project_flutter/lib/api/in_app_browser.dart @@ -0,0 +1,36 @@ +import 'dart:io'; +import 'package:dafl_project_flutter/main.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; + +import 'track.dart'; + +class MyInAppBrowser extends InAppBrowser { + var options = InAppBrowserClassOptions( + crossPlatform: + InAppBrowserOptions(hideUrlBar: true, hideToolbarTop: true), + inAppWebViewGroupOptions: InAppWebViewGroupOptions( + crossPlatform: InAppWebViewOptions(javaScriptEnabled: true))); + + MyInAppBrowser() { + _debugBrowser(); + openUrlRequest( + urlRequest: URLRequest(url: MyApp.api.urlAuthorize), options: options); + } + + _debugBrowser() async { + if (Platform.isAndroid) { + await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); + } + } + + @override + Future onLoadStart(url) async { + if (url!.origin + url.path == MyApp.api.redirectUri) { + await MyApp.api.requestUserAuthorization(url); + /*String id = await MyApp.api.getCurrentlyPlayingTrack(); + Track track = await MyApp.api.getTrackInfo(id); + print('${track.artist} ${track.name} ${track.albumImage}');*/ + close(); + } + } +} diff --git a/Sources/dafl_project_flutter/lib/api/track.dart b/Sources/dafl_project_flutter/lib/api/track.dart new file mode 100644 index 0000000..f4658d6 --- /dev/null +++ b/Sources/dafl_project_flutter/lib/api/track.dart @@ -0,0 +1,11 @@ +class Track { + final String _artist; + final String _name; + final String _albumImage; + + Track(this._artist, this._name, this._albumImage); + + String get artist => _artist; + String get name => _name; + String get albumImage => _albumImage; +} diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 01b07d9..c5d8b8b 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -13,9 +13,10 @@ import '../model/music.dart'; import 'model/music.dart'; import 'model/spot.dart'; import 'model/user.dart'; +import 'package:rive/rive.dart'; +import 'api/api.dart'; void main() { - MyApp mainApp = MyApp(); runApp(MyApp()); } @@ -23,6 +24,7 @@ class MyApp extends StatelessWidget { Controller controller = Controller(); + static Api api = Api(); // This widget is the root of your application. @override Widget build(BuildContext context){ @@ -39,7 +41,7 @@ class MyApp extends StatelessWidget { } } -enum CardStatus { like, disLike, discovery, message} +enum CardStatus { like, disLike, discovery, message } class CardProvider extends ChangeNotifier{ List _spotsList = MyApp().controller.currentUser.Spots2; @@ -53,10 +55,6 @@ class CardProvider extends ChangeNotifier{ Offset get position => _position; double get angle => _angle; - - - - void setScreenSize(Size screenSize) => _screenSize = screenSize; void startPosition(DragStartDetails details) { @@ -79,7 +77,6 @@ class CardProvider extends ChangeNotifier{ final status = getStatus(force: true); - switch (status) { case CardStatus.like: like(context); @@ -97,6 +94,7 @@ class CardProvider extends ChangeNotifier{ resetPosition(); } } + void resetPosition() { _isDragging = false; _position = Offset.zero; @@ -119,33 +117,35 @@ class CardProvider extends ChangeNotifier{ final forceDiscovery = x.abs() < 80; final forceMessage = x.abs() < 100; - if(force) { + if (force) { final delta = 100; if (x >= delta) { return CardStatus.like; - } else if ( x <= -delta){ + } else if (x <= -delta) { return CardStatus.disLike; - } else if ( y <= -delta/2 && forceDiscovery){ + } else if (y <= -delta / 2 && forceDiscovery) { return CardStatus.message; } else if (y >= delta * 2 && x.abs() < 100) { return CardStatus.discovery; } - } else{ + } else { final delta = 20; - if(y <= -delta * 2 && forceDiscovery) { + if (y <= -delta * 2 && forceDiscovery) { return CardStatus.message; - } else if (y >= delta *2 && x.abs() < 80) { + } else if (y >= delta * 2 && x.abs() < 80) { return CardStatus.discovery; - }else if ( x >= delta) { + } else if (x >= delta) { return CardStatus.like; - } else if ( x <= -delta) { + } else if (x <= -delta) { return CardStatus.disLike; } } } + void dislike() { + Vibration.vibrate(duration: 20, amplitude: 60); print("dislike"); _angle = -20; _position -= Offset(2 * _screenSize.width, 0); @@ -155,6 +155,8 @@ class CardProvider extends ChangeNotifier{ } void discovery() { + Vibration.vibrate(duration: 20, amplitude: 60); + print("discovery"); _angle = 0; _position -= Offset(0, -_screenSize.height); _discovery_card(); @@ -189,6 +191,7 @@ class CardProvider extends ChangeNotifier{ } void message(context) { + Vibration.vibrate(duration: 20, amplitude: 60); print("message"); _angle = 0; _position -= Offset(0, _screenSize.height); @@ -200,10 +203,11 @@ class CardProvider extends ChangeNotifier{ backgroundColor: Colors.transparent, context: context, constraints: BoxConstraints( - maxWidth: 600, + maxWidth: 600, maxHeight: double.infinity, ), - builder: (context) => buildSheet(),); + builder: (context) => buildSheet(), + ); notifyListeners(); } Widget buildSheet(){ @@ -317,12 +321,12 @@ class CardProvider extends ChangeNotifier{ void like(context) { + Vibration.vibrate(duration: 20, amplitude: 60); print("like"); _angle = 20; _position += Offset(2 * _screenSize.width, 0); _nextCard(); notifyListeners(); - } Future _nextCard() async { @@ -348,10 +352,8 @@ class CardProvider extends ChangeNotifier{ await Future.delayed(Duration(milliseconds: 200)); resetPosition(); } - } - class Splash extends StatefulWidget { const Splash({Key? key}) : super(key: key); @@ -360,7 +362,6 @@ class Splash extends StatefulWidget { } class _SplashState extends State { - @override void initState() { super.initState(); @@ -373,11 +374,8 @@ class _SplashState extends State { ); }); }); - - } - @override Widget build(BuildContext context) { return Scaffold( diff --git a/Sources/dafl_project_flutter/lib/views/pages/home/p_home.dart b/Sources/dafl_project_flutter/lib/views/pages/home/p_home.dart index 781c451..1720a0d 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/home/p_home.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/home/p_home.dart @@ -14,7 +14,7 @@ class _HomePageState extends State { double height = MediaQuery.of(context).size.height; double width = MediaQuery.of(context).size.width; return Scaffold( - backgroundColor: Color(0xFF141414), + backgroundColor: const Color(0xFF141414), body: Stack( alignment: AlignmentDirectional.topCenter, children: [ @@ -33,68 +33,116 @@ class _HomePageState extends State { 'assets/images/Logo.png', width: 230, ), - SizedBox(height: height*0.08,), + SizedBox( + height: height * 0.04, + ), + SizedBox( + height: 55, + width: width * 0.75, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF24CF5F), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15.0), + ), // background// foreground + ), + onPressed: () {}, + child: const Text( + "CONTINUER AVEC SPOTIFY", + style: TextStyle( + color: Colors.white, + fontSize: 17, + fontWeight: FontWeight.bold), + textAlign: TextAlign.center, + ), + ), + ), + SizedBox( + height: height * 0.015, + ), + SizedBox( + height: height * 0.08, + ), SizedBox( height: 55, - width: width*0.75, + width: width * 0.75, child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF5C1DC3), + backgroundColor: const Color(0xFF5C1DC3), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), - ),// background// foreground + ), // background// foreground ), onPressed: () { - Navigator.of(context).push(PageTransition( - duration: Duration(milliseconds: 300), - reverseDuration: Duration(milliseconds: 300), - type: PageTransitionType.rightToLeftJoined, - childCurrent: widget, - child: SignUpPage()), + Navigator.of(context).push( + PageTransition( + duration: const Duration(milliseconds: 300), + reverseDuration: const Duration(milliseconds: 300), + type: PageTransitionType.rightToLeftJoined, + childCurrent: widget, + child: const SignUpPage()), ); }, - child: Text("S’INSCRIRE MAINTENANT", - style: TextStyle(color: Colors.white ,fontSize: 17, fontWeight: FontWeight.bold), + child: const Text( + "S’INSCRIRE MAINTENANT", + style: TextStyle( + color: Colors.white, + fontSize: 17, + fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), - ),), + ), + ), Spacer(), GestureDetector( - onTap: (){ + onTap: () { Navigator.of(context).push( PageTransition( - duration: Duration(milliseconds: 300), - reverseDuration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), + reverseDuration: const Duration(milliseconds: 300), type: PageTransitionType.rightToLeftJoined, childCurrent: widget, - child: SignInPage()), + child: const SignInPage()), ); }, child: Container( - child: Align( + child: const Align( alignment: Alignment.center, - child: Text("SE CONNECTER", - style: TextStyle(color: Colors.white ,fontSize: 17, fontWeight: FontWeight.bold), + child: Text( + "SE CONNECTER", + style: TextStyle( + color: Colors.white, + fontSize: 17, + fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), ), - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + margin: const EdgeInsets.fromLTRB(0, 0, 0, 0), width: double.infinity, height: 80, - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Color(0xFF232123), border: Border( top: BorderSide(width: 1.5, color: Color(0xFF3C3C3C)), - ),// Set rounded corner radius - + ), // Set rounded corner radius ), ), ), - - ], ), - + Align( + alignment: Alignment.topRight, + child: Container( + padding: const EdgeInsets.fromLTRB(0, 20, 20, 0), + child: Text( + "v1.0", + style: TextStyle( + fontFamily: 'DMSans', + color: Colors.white.withOpacity(0.5), + fontSize: 17, + fontWeight: FontWeight.w700), + ), + )), ], ), ); 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 800c8c0..f337fa9 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,6 +1,9 @@ import 'package:dafl_project_flutter/main.dart'; +import 'package:dafl_project_flutter/api/api.dart'; +import 'package:dafl_project_flutter/main.dart'; import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; +import '../../../api/in_app_browser.dart'; import 'package:rive/rive.dart' as riv; import '../../../model/user.dart'; import '../home/p_home.dart'; @@ -15,7 +18,6 @@ class SignUpPage extends StatefulWidget { } class _SignUpPageState extends State { - Color boxColor = Colors.white; bool isHovering = false; @override @@ -24,9 +26,10 @@ class _SignUpPageState extends State { final passwordTextField = TextEditingController(); final passwordConfirmTextField = TextEditingController(); Widget build(BuildContext context) { + double width = MediaQuery.of(context).size.width; return Scaffold( resizeToAvoidBottomInset: false, - backgroundColor: Color(0xFF141414), + backgroundColor: const Color(0xFF141414), body: Stack( alignment: AlignmentDirectional.topCenter, children: [ @@ -40,40 +43,49 @@ class _SignUpPageState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [ - Image.asset( 'assets/images/Logo.png', width: 250, ), - SizedBox(height: 45,), - Text( + const SizedBox( + height: 45, + ), + const Text( "S'INSCRIRE", - style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 23, fontWeight: FontWeight.w700), + style: TextStyle( + fontFamily: 'DMSans', + color: Colors.white, + fontSize: 23, + fontWeight: FontWeight.w700), textAlign: TextAlign.center, ), - SizedBox(height: 10,), + const SizedBox( + height: 10, + ), Container( width: 500, - padding: EdgeInsets.fromLTRB(45, 0, 45, 0), + padding: const EdgeInsets.fromLTRB(45, 0, 45, 0), child: Stack( children: [ Container( height: 43, decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(50)), + borderRadius: + const BorderRadius.all(Radius.circular(50)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), spreadRadius: 5, blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow + offset: const Offset( + 0, 3), // changes position of shadow ), ], ), ), - Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), + const Padding( + padding: EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( controller: userNameTextField, decoration: InputDecoration( @@ -84,7 +96,7 @@ class _SignUpPageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(15, 12, 0, 0), + margin: const EdgeInsets.fromLTRB(15, 12, 0, 0), child: Image.asset( 'assets/images/profil_logo.png', height: 16, @@ -93,31 +105,31 @@ class _SignUpPageState extends State { ), ), ], - ) - ), + )), Container( width: 500, - padding: EdgeInsets.fromLTRB(45, 10, 45, 0), + padding: const EdgeInsets.fromLTRB(45, 10, 45, 0), child: Stack( children: [ Container( height: 43, decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(50)), + borderRadius: + const BorderRadius.all(Radius.circular(50)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), spreadRadius: 5, blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow + offset: const Offset( + 0, 3), // changes position of shadow ), ], - ), - - ),Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), + ), + const Padding( + padding: EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( controller: passwordTextField, obscureText: true, @@ -129,7 +141,7 @@ class _SignUpPageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(15, 12, 0, 0), + margin: const EdgeInsets.fromLTRB(15, 12, 0, 0), child: Image.asset( 'assets/images/password_logo.png', height: 16, @@ -138,31 +150,31 @@ class _SignUpPageState extends State { ), ), ], - ) - ), + )), Container( width: 500, - padding: EdgeInsets.fromLTRB(45, 10, 45, 0), + padding: const EdgeInsets.fromLTRB(45, 10, 45, 0), child: Stack( children: [ Container( height: 43, decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(50)), + borderRadius: + const BorderRadius.all(Radius.circular(50)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), spreadRadius: 5, blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow + offset: const Offset( + 0, 3), // changes position of shadow ), ], - ), - - ),Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), + ), + Padding( + padding: const EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( obscureText: true, controller: passwordConfirmTextField, @@ -174,7 +186,7 @@ class _SignUpPageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(15, 12, 0, 0), + margin: const EdgeInsets.fromLTRB(15, 12, 0, 0), child: Image.asset( 'assets/images/password_logo.png', height: 16, @@ -183,58 +195,70 @@ class _SignUpPageState extends State { ), ), ], - ) - ), + )), Container( width: 500, - padding: EdgeInsets.fromLTRB(45, 10, 45, 0), + padding: const EdgeInsets.fromLTRB(45, 10, 45, 0), child: Stack( children: [ Container( height: 43, decoration: BoxDecoration( - color: Color(0xFF24CF5F), - borderRadius: BorderRadius.all( - Radius.circular(50)), + color: const Color(0xFF24CF5F), + borderRadius: + const BorderRadius.all(Radius.circular(50)), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), spreadRadius: 5, blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow + offset: const Offset( + 0, 3), // changes position of shadow ), ], - ), ), - Padding( - padding: EdgeInsets.fromLTRB(0, 10, 10, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Lier compte ", - style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 18, fontWeight: FontWeight.w700), - textAlign: TextAlign.center, - ), - Image.asset( - 'assets/images/spotify_logo.png', - height: 25, - width: 25, - fit: BoxFit.cover, - ), - ], - ),), - + SizedBox( + height: 43, + width: width * 0.75, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF24CF5F), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(100), + ), // background// foreground + ), + onPressed: () { + MyInAppBrowser(); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + "Lier compte", + style: TextStyle( + fontFamily: 'DMSans', + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w700), + ), + Image.asset( + 'assets/images/spotify_logo.png', + height: 25, + width: 25, + fit: BoxFit.cover, + ), + ], + )), + ), ], - ) + )), + const SizedBox( + height: 30, ), - SizedBox(height: 30,), ClipRRect( borderRadius: BorderRadius.circular(22), - child: Material( - child: InkWell( highlightColor: Colors.grey.shade100, splashColor: Color(0xFF406DE1), @@ -255,13 +279,14 @@ class _SignUpPageState extends State { width: 83, height: 83, decoration: BoxDecoration( - color: Colors.white,// Set rounded corner radius + color: Colors.white, // Set rounded corner radius boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), spreadRadius: 5, blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow + offset: const Offset( + 0, 3), // changes position of shadow ), ], ), @@ -270,26 +295,39 @@ class _SignUpPageState extends State { ), ), ), - SizedBox(height: 100,), + const SizedBox( + height: 100, + ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('Tu as déjà un compte ?', style: TextStyle(color: Colors.white, fontWeight: FontWeight.normal, fontSize: 17)), + const Text('Tu as déjà un compte ?', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.normal, + fontSize: 17)), GestureDetector( onTap: () { Navigator.of(context).push( PageTransition( type: PageTransitionType.fade, childCurrent: widget, - child: SignInPage()), + child: const SignInPage()), ); }, - child: Text(' se connecter', style: TextStyle(color: Color(0xFF406DE1), fontWeight: FontWeight.normal, fontSize: 16), + child: const Text( + ' se connecter', + style: TextStyle( + color: Color(0xFF406DE1), + fontWeight: FontWeight.normal, + fontSize: 16), ), ), ], ), - SizedBox(height: 60,), + const SizedBox( + height: 60, + ), ], ), diff --git a/Sources/dafl_project_flutter/pubspec.lock b/Sources/dafl_project_flutter/pubspec.lock index 1ffe1de..85a066d 100644 --- a/Sources/dafl_project_flutter/pubspec.lock +++ b/Sources/dafl_project_flutter/pubspec.lock @@ -132,6 +132,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: @@ -199,7 +206,7 @@ packages: source: hosted version: "0.15.1" http: - dependency: transitive + dependency: "direct main" description: name: http url: "https://pub.dartlang.org" @@ -387,6 +394,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.0.4" + random_string: + dependency: "direct main" + description: + name: random_string + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" rikulo_commons: dependency: transitive description: diff --git a/Sources/dafl_project_flutter/pubspec.yaml b/Sources/dafl_project_flutter/pubspec.yaml index 6a0181b..f2c68c1 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 @@ -43,6 +20,9 @@ dependencies: animations: ^2.0.7 fluttertoast: ^8.1.1 vibration: ^1.7.6 + flutter_inappwebview: ^5.7.1 + http: ^0.13.5 + random_string: ^2.3.1 postgresql2: ^1.0.3 path_provider: ^2.0.11 font_awesome_flutter: ^10.2.1 @@ -53,11 +33,6 @@ 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 @@ -71,11 +46,6 @@ flutter_native_splash: #background_image: "assets/images/background_blur.png" image: "assets/images/icon_App.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: image_path_android: "assets/images/icon_App.png" image_path_ios: "assets/images/icon_App.png" @@ -83,28 +53,11 @@ flutter_icons: ios: true 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: @@ -122,5 +75,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