non matching drop down background fix

option to add genius access_token on Login Screen
red logout button
This commit is contained in:
Kingkor Roy Tirtho 2022-02-02 13:27:23 +06:00
parent 44b1921171
commit 350fc75803
3 changed files with 93 additions and 60 deletions

View File

@ -1,8 +1,12 @@
import 'package:flutter/material.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/helpers/oauth-login.dart';
import 'package:spotube/models/LocalStorageKeys.dart';
import 'package:spotube/provider/Auth.dart';
import 'package:spotube/provider/UserPreferences.dart';
class Login extends StatefulWidget {
const Login({Key? key}) : super(key: key);
@ -14,9 +18,10 @@ class Login extends StatefulWidget {
class _LoginState extends State<Login> {
String clientId = "";
String clientSecret = "";
String accessToken = "";
bool _fieldError = false;
handleLogin(Auth authState) async {
Future handleLogin(Auth authState) async {
try {
if (clientId == "" || clientSecret == "") {
return setState(() {
@ -35,67 +40,91 @@ class _LoginState extends State<Login> {
builder: (context, authState, child) {
return Scaffold(
appBar: const PageWindowTitleBar(),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/spotube-logo.png",
width: 400,
height: 400,
),
Text("Add your spotify credentials to get started",
style: Theme.of(context).textTheme.headline4),
const Text(
"Don't worry, any of your credentials won't be collected or shared with anyone"),
const SizedBox(
height: 10,
),
Container(
constraints: const BoxConstraints(
maxWidth: 400,
body: SingleChildScrollView(
child: Center(
child: Column(
children: [
Image.asset(
"assets/spotube-logo.png",
width: 400,
height: 400,
),
child: Column(
children: [
TextField(
decoration: const InputDecoration(
hintText: "Spotify Client ID",
label: Text("ClientID"),
),
onChanged: (value) {
setState(() {
clientId = value;
});
},
),
const SizedBox(
height: 10,
),
TextField(
decoration: const InputDecoration(
hintText: "Spotify Client Secret",
label: Text("Client Secret"),
),
onChanged: (value) {
setState(() {
clientSecret = value;
});
},
),
const SizedBox(
height: 10,
),
ElevatedButton(
onPressed: () {
handleLogin(authState);
},
child: const Text("Submit"),
)
],
Text("Add your spotify credentials to get started",
style: Theme.of(context).textTheme.headline4),
const Text(
"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(
height: 10,
),
),
],
Container(
constraints: const BoxConstraints(
maxWidth: 400,
),
child: Column(
children: [
TextField(
decoration: const InputDecoration(
hintText: "Spotify Client ID",
label: Text("ClientID"),
),
onChanged: (value) {
setState(() {
clientId = value;
});
},
),
const SizedBox(height: 10),
TextField(
decoration: const InputDecoration(
hintText: "Spotify Client Secret",
label: Text("Client Secret"),
),
onChanged: (value) {
setState(() {
clientSecret = value;
});
},
),
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(
height: 10,
),
ElevatedButton(
onPressed: () async {
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"),
)
],
),
),
],
),
),
),
);

View File

@ -135,6 +135,9 @@ class _SettingsState extends State<Settings> {
const Text("Log out of this account"),
ElevatedButton(
child: const Text("Logout"),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.red),
),
onPressed: () async {
SharedPreferences localStorage =
await SharedPreferences.getInstance();

View File

@ -200,6 +200,7 @@ class _MyAppState extends State<MyApp> {
color: Colors.blueGrey[900],
elevation: 20,
),
canvasColor: Colors.blueGrey[900],
),
themeMode: _themeMode,
home: const Home(),