fix(authorization): android no redirecting to app after login when device locale isn't set to en

This commit is contained in:
Kingkor Roy Tirtho 2022-10-05 12:19:40 +06:00
parent 677f3dcf29
commit 0653dab6ee
3 changed files with 74 additions and 35 deletions

View File

@ -41,7 +41,9 @@ class WebViewLogin extends HookConsumerWidget {
url = url.substring(0, url.length - 1); url = url.substring(0, url.length - 1);
} }
if (url == "https://accounts.spotify.com/en/status") { final exp = RegExp(r"https:\/\/accounts.spotify.com\/\w+\/status");
if (exp.hasMatch(url)) {
final cookies = final cookies =
await CookieManager.instance().getCookies(url: action); await CookieManager.instance().getCookies(url: action);
final cookieHeader = final cookieHeader =

View File

@ -74,14 +74,21 @@ class Settings extends HookConsumerWidget {
Icons.login_rounded, Icons.login_rounded,
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
), ),
title: AutoSizeText( title: SizedBox(
"Login with your Spotify account", height: 50,
style: TextStyle( width: 200,
color: Theme.of(context).primaryColor, child: Align(
alignment: Alignment.centerLeft,
child: AutoSizeText(
"Login with your Spotify account",
maxLines: 1,
style: TextStyle(
color: Theme.of(context).primaryColor,
),
),
), ),
), ),
trailing: (context, update) => ElevatedButton( trailing: (context, update) => ElevatedButton(
child: Text("Connect with Spotify".toUpperCase()),
onPressed: () { onPressed: () {
GoRouter.of(context).push("/login"); GoRouter.of(context).push("/login");
}, },
@ -92,6 +99,7 @@ class Settings extends HookConsumerWidget {
), ),
), ),
), ),
child: Text("Connect with Spotify".toUpperCase()),
), ),
), ),
if (auth.isLoggedIn) if (auth.isLoggedIn)
@ -99,12 +107,18 @@ class Settings extends HookConsumerWidget {
Auth auth = ref.watch(authProvider); Auth auth = ref.watch(authProvider);
return ListTile( return ListTile(
leading: const Icon(Icons.logout_rounded), leading: const Icon(Icons.logout_rounded),
title: const AutoSizeText( title: const SizedBox(
"Log out of this account", height: 50,
maxLines: 1, width: 180,
child: Align(
alignment: Alignment.centerLeft,
child: AutoSizeText(
"Log out of this account",
maxLines: 1,
),
),
), ),
trailing: ElevatedButton( trailing: ElevatedButton(
child: const Text("Logout"),
style: ButtonStyle( style: ButtonStyle(
backgroundColor: backgroundColor:
MaterialStateProperty.all(Colors.red), MaterialStateProperty.all(Colors.red),
@ -115,6 +129,7 @@ class Settings extends HookConsumerWidget {
auth.logout(); auth.logout();
GoRouter.of(context).pop(); GoRouter.of(context).pop();
}, },
child: const Text("Logout"),
), ),
); );
}), }),
@ -133,20 +148,20 @@ class Settings extends HookConsumerWidget {
value: preferences.layoutMode, value: preferences.layoutMode,
items: const [ items: const [
DropdownMenuItem( DropdownMenuItem(
value: LayoutMode.adaptive,
child: Text( child: Text(
"Adaptive", "Adaptive",
), ),
value: LayoutMode.adaptive,
), ),
DropdownMenuItem( DropdownMenuItem(
value: LayoutMode.compact,
child: Text( child: Text(
"Compact", "Compact",
), ),
value: LayoutMode.compact,
), ),
DropdownMenuItem( DropdownMenuItem(
child: Text("Extended"),
value: LayoutMode.extended, value: LayoutMode.extended,
child: Text("Extended"),
), ),
], ],
onChanged: (value) { onChanged: (value) {
@ -164,20 +179,20 @@ class Settings extends HookConsumerWidget {
value: preferences.themeMode, value: preferences.themeMode,
items: const [ items: const [
DropdownMenuItem( DropdownMenuItem(
value: ThemeMode.dark,
child: Text( child: Text(
"Dark", "Dark",
), ),
value: ThemeMode.dark,
), ),
DropdownMenuItem( DropdownMenuItem(
value: ThemeMode.light,
child: Text( child: Text(
"Light", "Light",
), ),
value: ThemeMode.light,
), ),
DropdownMenuItem( DropdownMenuItem(
child: Text("System"),
value: ThemeMode.system, value: ThemeMode.system,
child: Text("System"),
), ),
], ],
onChanged: (value) { onChanged: (value) {
@ -229,14 +244,14 @@ class Settings extends HookConsumerWidget {
value: preferences.audioQuality, value: preferences.audioQuality,
items: const [ items: const [
DropdownMenuItem( DropdownMenuItem(
value: AudioQuality.high,
child: Text( child: Text(
"High", "High",
), ),
value: AudioQuality.high,
), ),
DropdownMenuItem( DropdownMenuItem(
child: Text("Low"),
value: AudioQuality.low, value: AudioQuality.low,
child: Text("Low"),
), ),
], ],
onChanged: (value) { onChanged: (value) {
@ -283,8 +298,8 @@ class Settings extends HookConsumerWidget {
items: spotifyMarkets items: spotifyMarkets
.map( .map(
(country) => (DropdownMenuItem( (country) => (DropdownMenuItem(
child: Text(country.last),
value: country.first, value: country.first,
child: Text(country.last),
)), )),
) )
.toList(), .toList(),
@ -300,9 +315,16 @@ class Settings extends HookConsumerWidget {
), ),
AdaptiveListTile( AdaptiveListTile(
leading: const Icon(Icons.screen_search_desktop_rounded), leading: const Icon(Icons.screen_search_desktop_rounded),
title: const AutoSizeText( title: const SizedBox(
"Format of the YouTube Search term", height: 50,
maxLines: 2, width: 200,
child: Align(
alignment: Alignment.centerLeft,
child: AutoSizeText(
"Format of the YouTube Search term",
maxLines: 2,
),
),
), ),
subtitle: const Text("(Case sensitive)"), subtitle: const Text("(Case sensitive)"),
breakOn: Breakpoints.lg, breakOn: Breakpoints.lg,
@ -330,29 +352,36 @@ class Settings extends HookConsumerWidget {
), ),
AdaptiveListTile( AdaptiveListTile(
leading: const Icon(Icons.low_priority_rounded), leading: const Icon(Icons.low_priority_rounded),
title: const AutoSizeText( title: const SizedBox(
"Track Match Algorithm", height: 50,
maxLines: 1, width: 180,
child: Align(
alignment: Alignment.centerLeft,
child: AutoSizeText(
"Track Match Algorithm",
maxLines: 1,
),
),
), ),
trailing: (context, update) => trailing: (context, update) =>
DropdownButton<SpotubeTrackMatchAlgorithm>( DropdownButton<SpotubeTrackMatchAlgorithm>(
value: preferences.trackMatchAlgorithm, value: preferences.trackMatchAlgorithm,
items: const [ items: const [
DropdownMenuItem( DropdownMenuItem(
value: SpotubeTrackMatchAlgorithm.authenticPopular,
child: Text( child: Text(
"Popular from Author", "Popular from Author",
), ),
value: SpotubeTrackMatchAlgorithm.authenticPopular,
), ),
DropdownMenuItem( DropdownMenuItem(
value: SpotubeTrackMatchAlgorithm.popular,
child: Text( child: Text(
"Accurately Popular", "Accurately Popular",
), ),
value: SpotubeTrackMatchAlgorithm.popular,
), ),
DropdownMenuItem( DropdownMenuItem(
child: Text("YouTube's Top choice"),
value: SpotubeTrackMatchAlgorithm.youtube, value: SpotubeTrackMatchAlgorithm.youtube,
child: Text("YouTube's Top choice"),
), ),
], ],
onChanged: (value) { onChanged: (value) {
@ -373,8 +402,8 @@ class Settings extends HookConsumerWidget {
title: const Text("Download Location"), title: const Text("Download Location"),
subtitle: Text(preferences.downloadLocation), subtitle: Text(preferences.downloadLocation),
trailing: ElevatedButton( trailing: ElevatedButton(
child: const Icon(Icons.folder_rounded),
onPressed: pickDownloadLocation, onPressed: pickDownloadLocation,
child: const Icon(Icons.folder_rounded),
), ),
onTap: pickDownloadLocation, onTap: pickDownloadLocation,
), ),
@ -399,12 +428,19 @@ class Settings extends HookConsumerWidget {
Icons.favorite_border_rounded, Icons.favorite_border_rounded,
color: Colors.pink, color: Colors.pink,
), ),
title: const AutoSizeText( title: const SizedBox(
"We know you Love Spotube", height: 50,
maxLines: 1, width: 200,
style: TextStyle( child: Align(
color: Colors.pink, alignment: Alignment.centerLeft,
fontWeight: FontWeight.bold, child: AutoSizeText(
"We know you Love Spotube",
maxLines: 1,
style: TextStyle(
color: Colors.pink,
fontWeight: FontWeight.bold,
),
),
), ),
), ),
trailing: (context, update) => ElevatedButton.icon( trailing: (context, update) => ElevatedButton.icon(

View File

@ -40,6 +40,7 @@ class AdaptiveListTile extends HookWidget {
return AlertDialog( return AlertDialog(
title: title != null title: title != null
? Row( ? Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
if (leading != null) ...[ if (leading != null) ...[
leading!, leading!,