mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
non matching drop down background fix
option to add genius access_token on Login Screen red logout button
This commit is contained in:
parent
44b1921171
commit
350fc75803
@ -1,8 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:spotube/components/Shared/Hyperlink.dart';
|
||||||
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
|
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
|
||||||
import 'package:spotube/helpers/oauth-login.dart';
|
import 'package:spotube/helpers/oauth-login.dart';
|
||||||
|
import 'package:spotube/models/LocalStorageKeys.dart';
|
||||||
import 'package:spotube/provider/Auth.dart';
|
import 'package:spotube/provider/Auth.dart';
|
||||||
|
import 'package:spotube/provider/UserPreferences.dart';
|
||||||
|
|
||||||
class Login extends StatefulWidget {
|
class Login extends StatefulWidget {
|
||||||
const Login({Key? key}) : super(key: key);
|
const Login({Key? key}) : super(key: key);
|
||||||
@ -14,9 +18,10 @@ class Login extends StatefulWidget {
|
|||||||
class _LoginState extends State<Login> {
|
class _LoginState extends State<Login> {
|
||||||
String clientId = "";
|
String clientId = "";
|
||||||
String clientSecret = "";
|
String clientSecret = "";
|
||||||
|
String accessToken = "";
|
||||||
bool _fieldError = false;
|
bool _fieldError = false;
|
||||||
|
|
||||||
handleLogin(Auth authState) async {
|
Future handleLogin(Auth authState) async {
|
||||||
try {
|
try {
|
||||||
if (clientId == "" || clientSecret == "") {
|
if (clientId == "" || clientSecret == "") {
|
||||||
return setState(() {
|
return setState(() {
|
||||||
@ -35,10 +40,9 @@ class _LoginState extends State<Login> {
|
|||||||
builder: (context, authState, child) {
|
builder: (context, authState, child) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const PageWindowTitleBar(),
|
appBar: const PageWindowTitleBar(),
|
||||||
body: Center(
|
body: SingleChildScrollView(
|
||||||
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
"assets/spotube-logo.png",
|
"assets/spotube-logo.png",
|
||||||
@ -49,6 +53,8 @@ class _LoginState extends State<Login> {
|
|||||||
style: Theme.of(context).textTheme.headline4),
|
style: Theme.of(context).textTheme.headline4),
|
||||||
const Text(
|
const Text(
|
||||||
"Don't worry, any of your credentials won't be collected or shared with anyone"),
|
"Don't worry, any of your credentials won't be collected or shared with anyone"),
|
||||||
|
const Hyperlink("How to get these client-id & client-secret?",
|
||||||
|
"https://github.com/KRTirtho/spotube#configuration"),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
@ -69,9 +75,7 @@ class _LoginState extends State<Login> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(height: 10),
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
TextField(
|
TextField(
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: "Spotify Client Secret",
|
hintText: "Spotify Client Secret",
|
||||||
@ -83,12 +87,36 @@ class _LoginState extends State<Login> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Divider(color: Colors.grey),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
label: Text("Genius Access Token (optional)"),
|
||||||
|
),
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
accessToken = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
handleLogin(authState);
|
await handleLogin(authState);
|
||||||
|
UserPreferences preferences =
|
||||||
|
context.read<UserPreferences>();
|
||||||
|
SharedPreferences localStorage =
|
||||||
|
await SharedPreferences.getInstance();
|
||||||
|
preferences.setGeniusAccessToken(accessToken);
|
||||||
|
await localStorage.setString(
|
||||||
|
LocalStorageKeys.geniusAccessToken,
|
||||||
|
accessToken);
|
||||||
|
setState(() {
|
||||||
|
accessToken = "";
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: const Text("Submit"),
|
child: const Text("Submit"),
|
||||||
)
|
)
|
||||||
@ -98,6 +126,7 @@ class _LoginState extends State<Login> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -135,6 +135,9 @@ class _SettingsState extends State<Settings> {
|
|||||||
const Text("Log out of this account"),
|
const Text("Log out of this account"),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: const Text("Logout"),
|
child: const Text("Logout"),
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: MaterialStateProperty.all(Colors.red),
|
||||||
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
SharedPreferences localStorage =
|
SharedPreferences localStorage =
|
||||||
await SharedPreferences.getInstance();
|
await SharedPreferences.getInstance();
|
||||||
|
@ -200,6 +200,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
color: Colors.blueGrey[900],
|
color: Colors.blueGrey[900],
|
||||||
elevation: 20,
|
elevation: 20,
|
||||||
),
|
),
|
||||||
|
canvasColor: Colors.blueGrey[900],
|
||||||
),
|
),
|
||||||
themeMode: _themeMode,
|
themeMode: _themeMode,
|
||||||
home: const Home(),
|
home: const Home(),
|
||||||
|
Loading…
Reference in New Issue
Block a user