Début implementation API

pull/82/head
Félix MIELCAREK 3 years ago
parent 5b7757a2b6
commit 8c846dca5c

@ -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<void> 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));
}
}

@ -1,3 +1,4 @@
import 'package:dafl_project_flutter/spotify_api/api.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:page_transition/page_transition.dart'; import 'package:page_transition/page_transition.dart';
import '../home/p_home.dart'; import '../home/p_home.dart';
@ -11,16 +12,18 @@ class SignUpPage extends StatefulWidget {
} }
class _SignUpPageState extends State<SignUpPage> { class _SignUpPageState extends State<SignUpPage> {
Color boxColor = Colors.white; Color boxColor = Colors.white;
bool isHovering = false; bool isHovering = false;
@override TextEditingController passwordconfirm = TextEditingController();
TextEditingController passwordconfirm = new TextEditingController();
bool isChecked = false; bool isChecked = false;
Api apiSptfy = Api();
Future<void>? _launched;
@override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: Color(0xFF141414), backgroundColor: const Color(0xFF141414),
body: Stack( body: Stack(
alignment: AlignmentDirectional.topCenter, alignment: AlignmentDirectional.topCenter,
children: <Widget>[ children: <Widget>[
@ -34,40 +37,49 @@ class _SignUpPageState extends State<SignUpPage> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Image.asset( Image.asset(
'assets/images/Logo.png', 'assets/images/Logo.png',
width: 250, width: 250,
), ),
SizedBox(height: 45,), const SizedBox(
Text( height: 45,
),
const Text(
"S'INSCRIRE", "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, textAlign: TextAlign.center,
), ),
SizedBox(height: 10,), const SizedBox(
height: 10,
),
Container( Container(
width: 500, width: 500,
padding: EdgeInsets.fromLTRB(45, 0, 45, 0), padding: const EdgeInsets.fromLTRB(45, 0, 45, 0),
child: Stack( child: Stack(
children: [ children: [
Container( Container(
height: 43, height: 43,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all( borderRadius:
Radius.circular(50)), const BorderRadius.all(Radius.circular(50)),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
spreadRadius: 5, spreadRadius: 5,
blurRadius: 7, 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( child: TextField(
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
@ -77,7 +89,7 @@ class _SignUpPageState extends State<SignUpPage> {
), ),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(15, 12, 0, 0), margin: const EdgeInsets.fromLTRB(15, 12, 0, 0),
child: Image.asset( child: Image.asset(
'assets/images/profil_logo.png', 'assets/images/profil_logo.png',
height: 16, height: 16,
@ -86,31 +98,31 @@ class _SignUpPageState extends State<SignUpPage> {
), ),
), ),
], ],
) )),
),
Container( Container(
width: 500, width: 500,
padding: EdgeInsets.fromLTRB(45, 10, 45, 0), padding: const EdgeInsets.fromLTRB(45, 10, 45, 0),
child: Stack( child: Stack(
children: [ children: [
Container( Container(
height: 43, height: 43,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all( borderRadius:
Radius.circular(50)), const BorderRadius.all(Radius.circular(50)),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
spreadRadius: 5, spreadRadius: 5,
blurRadius: 7, 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( child: TextField(
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
@ -120,7 +132,7 @@ class _SignUpPageState extends State<SignUpPage> {
), ),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(15, 12, 0, 0), margin: const EdgeInsets.fromLTRB(15, 12, 0, 0),
child: Image.asset( child: Image.asset(
'assets/images/password_logo.png', 'assets/images/password_logo.png',
height: 16, height: 16,
@ -129,34 +141,34 @@ class _SignUpPageState extends State<SignUpPage> {
), ),
), ),
], ],
) )),
),
Container( Container(
width: 500, width: 500,
padding: EdgeInsets.fromLTRB(45, 10, 45, 0), padding: const EdgeInsets.fromLTRB(45, 10, 45, 0),
child: Stack( child: Stack(
children: [ children: [
Container( Container(
height: 43, height: 43,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all( borderRadius:
Radius.circular(50)), const BorderRadius.all(Radius.circular(50)),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
spreadRadius: 5, spreadRadius: 5,
blurRadius: 7, 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( child: TextField(
controller: passwordconfirm, controller: passwordconfirm,
decoration: InputDecoration( decoration: const InputDecoration(
border: InputBorder.none, border: InputBorder.none,
), ),
cursorColor: Colors.purple, cursorColor: Colors.purple,
@ -164,7 +176,7 @@ class _SignUpPageState extends State<SignUpPage> {
), ),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(15, 12, 0, 0), margin: const EdgeInsets.fromLTRB(15, 12, 0, 0),
child: Image.asset( child: Image.asset(
'assets/images/password_logo.png', 'assets/images/password_logo.png',
height: 16, height: 16,
@ -173,39 +185,56 @@ class _SignUpPageState extends State<SignUpPage> {
), ),
), ),
], ],
) )),
),
Container( Container(
width: 500, width: 500,
padding: EdgeInsets.fromLTRB(45, 10, 45, 0), padding: const EdgeInsets.fromLTRB(45, 10, 45, 0),
child: Stack( child: Stack(
children: [ children: [
Container( Container(
height: 43, height: 43,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFF24CF5F), color: const Color(0xFF24CF5F),
borderRadius: BorderRadius.all( borderRadius:
Radius.circular(50)), const BorderRadius.all(Radius.circular(50)),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
spreadRadius: 5, spreadRadius: 5,
blurRadius: 7, blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow offset: const Offset(
0, 3), // changes position of shadow
), ),
], ],
), ),
), ),
Padding( SizedBox(
height: 55,
width: width * 0.75,
child: Padding(
padding: EdgeInsets.fromLTRB(0, 10, 10, 0), padding: EdgeInsets.fromLTRB(0, 10, 10, 0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text( 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 ", "Lier compte ",
style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 18, fontWeight: FontWeight.w700), style: TextStyle(
textAlign: TextAlign.center, fontFamily: 'DMSans',
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w700),
),
), ),
Image.asset( Image.asset(
'assets/images/spotify_logo.png', 'assets/images/spotify_logo.png',
@ -214,92 +243,108 @@ class _SignUpPageState extends State<SignUpPage> {
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
], ],
),), ),
),
),
], ],
) )),
const SizedBox(
height: 30,
), ),
SizedBox(height: 30,),
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
child: Material( child: Material(
child: InkWell( child: InkWell(
highlightColor: Colors.grey.shade100, highlightColor: Colors.grey.shade100,
splashColor: Color(0xFF406DE1), splashColor: const Color(0xFF406DE1),
onTap: (){ onTap: () {
setState(() { setState(() {
boxColor = Colors.blue; boxColor = Colors.blue;
}); });
Navigator.of(context).push( Navigator.of(context).push(
PageTransition( PageTransition(
duration: Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
reverseDuration: Duration(milliseconds: 300), reverseDuration: const Duration(milliseconds: 300),
type: PageTransitionType.leftToRightJoined, type: PageTransitionType.leftToRightJoined,
childCurrent: widget, childCurrent: widget,
child: HomePage()), child: HomePage()),
); );
}, },
child:Ink( child: Ink(
child: Align( padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
alignment: Alignment.center,
child: Image.asset(
'assets/images/valid_logo.png',
width: 47,
),
),
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
width: 83, width: 83,
height: 83, height: 83,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white,// Set rounded corner radius color: Colors.white, // Set rounded corner radius
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colors.black.withOpacity(0.3), color: Colors.black.withOpacity(0.3),
spreadRadius: 5, spreadRadius: 5,
blurRadius: 7, 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( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text('Tu nas déjà un compte?', style: TextStyle(color: Colors.white, fontWeight: FontWeight.normal, fontSize: 17)), const Text('Tu nas déjà un compte?',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.normal,
fontSize: 17)),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
Navigator.of(context).push( Navigator.of(context).push(
PageTransition( PageTransition(
type: PageTransitionType.fade, type: PageTransitionType.fade,
childCurrent: widget, 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( Align(
alignment: Alignment.topRight, alignment: Alignment.topRight,
child: Container( child: Container(
padding: EdgeInsets.fromLTRB(0, 20, 20, 0), padding: const EdgeInsets.fromLTRB(0, 20, 20, 0),
child: Text("v1.0", child: Text(
style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(0.5) ,fontSize: 17, fontWeight: FontWeight.w700), "v1.0",
), style: TextStyle(
) fontFamily: 'DMSans',
), color: Colors.white.withOpacity(0.5),
fontSize: 17,
fontWeight: FontWeight.w700),
),
)),
], ],
), ),
); );

@ -233,6 +233,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.0" 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: provider:
dependency: "direct main" dependency: "direct main"
description: description:
@ -301,6 +308,62 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.1" 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: vector_math:
dependency: transitive dependency: transitive
description: description:

@ -42,6 +42,7 @@ dependencies:
rive: ^0.9.1 rive: ^0.9.1
animations: ^2.0.7 animations: ^2.0.7
fluttertoast: ^8.1.1 fluttertoast: ^8.1.1
url_launcher: ^6.1.6
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save