diff --git a/Sources/dafl_project_flutter/lib/spotify_api/api.dart b/Sources/dafl_project_flutter/lib/spotify_api/api.dart new file mode 100644 index 0000000..65df525 --- /dev/null +++ b/Sources/dafl_project_flutter/lib/spotify_api/api.dart @@ -0,0 +1,37 @@ +import 'package:url_launcher/url_launcher.dart'; +import 'dart:math'; + +class Api { + var clientId = '7ceb49d874b9404492246027e4d68cf8'; + var redirectUri = 'https://felixmielcarek.github.io'; + var state; + var scopes = 'user-read-private'; + var url; + + Api() { + state = generateRandomString(); + url = Uri.https('accounts.spotify.com', 'en/authorize', { + 'client_id': clientId, + 'response_type': 'code', + 'redirect_uri': redirectUri, + 'state': state, + 'scope': scopes, + 'show_dialog': 'true' + }); + } + + Future launchInBrowser() async { + if (!await launchUrl( + url, + mode: LaunchMode.externalApplication, + )) { + throw 'Could not launch $url'; + } + } + + String generateRandomString() { + var r = Random(); + return String.fromCharCodes( + List.generate(16, (index) => r.nextInt(33) + 89)); + } +} 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 167928d..e25ec92 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,3 +1,4 @@ +import 'package:dafl_project_flutter/spotify_api/api.dart'; import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; import '../home/p_home.dart'; @@ -11,16 +12,18 @@ class SignUpPage extends StatefulWidget { } class _SignUpPageState extends State { - Color boxColor = Colors.white; bool isHovering = false; - @override - TextEditingController passwordconfirm = new TextEditingController(); + TextEditingController passwordconfirm = TextEditingController(); bool isChecked = false; + Api apiSptfy = Api(); + Future? _launched; + @override 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: [ @@ -34,40 +37,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( decoration: InputDecoration( border: InputBorder.none, @@ -77,7 +89,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, @@ -86,31 +98,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( decoration: InputDecoration( border: InputBorder.none, @@ -120,7 +132,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, @@ -129,34 +141,34 @@ 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( controller: passwordconfirm, - decoration: InputDecoration( + decoration: const InputDecoration( border: InputBorder.none, ), cursorColor: Colors.purple, @@ -164,7 +176,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, @@ -173,133 +185,166 @@ 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: 55, + width: width * 0.75, + child: Padding( + padding: EdgeInsets.fromLTRB(0, 10, 10, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF24CF5F), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15.0), + ), + ), + onPressed: () => setState(() { + _launched = apiSptfy.launchInBrowser(); + }), + child: 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), - onTap: (){ + splashColor: const Color(0xFF406DE1), + onTap: () { setState(() { boxColor = Colors.blue; }); 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.leftToRightJoined, childCurrent: widget, child: HomePage()), ); }, - child:Ink( - child: Align( - alignment: Alignment.center, - child: Image.asset( - 'assets/images/valid_logo.png', - width: 47, - ), - ), - padding: EdgeInsets.fromLTRB(0, 10, 0, 0), + child: Ink( + padding: const EdgeInsets.fromLTRB(0, 10, 0, 0), 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 ), ], ), - + child: Align( + alignment: Alignment.center, + child: Image.asset( + 'assets/images/valid_logo.png', + width: 47, + ), + ), ), ), ), ), - SizedBox(height: 100,), + const SizedBox( + height: 100, + ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('Tu n’as déjà un compte?', style: TextStyle(color: Colors.white, fontWeight: FontWeight.normal, fontSize: 17)), + const Text('Tu n’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, + ), ], ), Align( alignment: Alignment.topRight, child: Container( - padding: 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), + 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/pubspec.lock b/Sources/dafl_project_flutter/pubspec.lock index 77f1c3e..c198312 100644 --- a/Sources/dafl_project_flutter/pubspec.lock +++ b/Sources/dafl_project_flutter/pubspec.lock @@ -233,6 +233,13 @@ 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: @@ -301,6 +308,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.1" + 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 7f5cd52..df7be09 100644 --- a/Sources/dafl_project_flutter/pubspec.yaml +++ b/Sources/dafl_project_flutter/pubspec.yaml @@ -42,6 +42,7 @@ dependencies: rive: ^0.9.1 animations: ^2.0.7 fluttertoast: ^8.1.1 + url_launcher: ^6.1.6 dev_dependencies: flutter_test: