Logout option
This commit is contained in:
parent
abf355779c
commit
4b3d264e2a
|
@ -1,6 +1,7 @@
|
||||||
import 'package:custom_navigator/custom_navigator.dart';
|
import 'package:custom_navigator/custom_navigator.dart';
|
||||||
import 'package:audio_service/audio_service.dart';
|
import 'package:audio_service/audio_service.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:freezer/ui/library.dart';
|
import 'package:freezer/ui/library.dart';
|
||||||
import 'package:freezer/ui/login_screen.dart';
|
import 'package:freezer/ui/login_screen.dart';
|
||||||
import 'package:freezer/ui/search.dart';
|
import 'package:freezer/ui/search.dart';
|
||||||
|
@ -14,7 +15,9 @@ import 'api/download.dart';
|
||||||
import 'api/player.dart';
|
import 'api/player.dart';
|
||||||
import 'ui/home_screen.dart';
|
import 'ui/home_screen.dart';
|
||||||
|
|
||||||
|
|
||||||
Function updateTheme;
|
Function updateTheme;
|
||||||
|
Function logOut;
|
||||||
GlobalKey<NavigatorState> mainNavigatorKey = GlobalKey<NavigatorState>();
|
GlobalKey<NavigatorState> mainNavigatorKey = GlobalKey<NavigatorState>();
|
||||||
GlobalKey<NavigatorState> navigatorKey;
|
GlobalKey<NavigatorState> navigatorKey;
|
||||||
|
|
||||||
|
@ -90,9 +93,21 @@ class _LoginMainWrapperState extends State<LoginMainWrapper> {
|
||||||
if (b) setState(() => settings.offlineMode = false);
|
if (b) setState(() => settings.offlineMode = false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//Global logOut function
|
||||||
|
logOut = _logOut;
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future _logOut() async {
|
||||||
|
setState(() {
|
||||||
|
settings.arl = null;
|
||||||
|
settings.offlineMode = true;
|
||||||
|
deezerAPI = new DeezerAPI();
|
||||||
|
});
|
||||||
|
await settings.save();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (settings.arl == null)
|
if (settings.arl == null)
|
||||||
|
|
|
@ -141,6 +141,8 @@ class _CachedImageState extends State<CachedImage> {
|
||||||
|
|
||||||
//Load image and fade
|
//Load image and fade
|
||||||
void _load() async {
|
void _load() async {
|
||||||
|
if (_prevUrl == widget.url) return;
|
||||||
|
|
||||||
ImageProvider image = await _getImage();
|
ImageProvider image = await _getImage();
|
||||||
if (_disposed) return;
|
if (_disposed) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -164,7 +166,6 @@ class _CachedImageState extends State<CachedImage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(CachedImage oldWidget) {
|
void didUpdateWidget(CachedImage oldWidget) {
|
||||||
if (_prevUrl == widget.url) return;
|
|
||||||
_load();
|
_load();
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
}
|
}
|
||||||
|
@ -183,6 +184,7 @@ class _CachedImageState extends State<CachedImage> {
|
||||||
height: widget.height,
|
height: widget.height,
|
||||||
width: widget.width,
|
width: widget.width,
|
||||||
),
|
),
|
||||||
|
|
||||||
AnimatedOpacity(
|
AnimatedOpacity(
|
||||||
duration: Duration(milliseconds: 250),
|
duration: Duration(milliseconds: 250),
|
||||||
opacity: _opacity,
|
opacity: _opacity,
|
||||||
|
|
|
@ -11,14 +11,31 @@ import '../settings.dart';
|
||||||
class HomeScreen extends StatelessWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
//TODO: SingleChildScrollView vs ListView speed/perf
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 16.0),
|
||||||
|
child: FreezerTitle(),
|
||||||
|
),
|
||||||
|
Flexible(child: HomePageScreen(),)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
/*
|
||||||
return ListView(
|
return ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(height: 16.0,),
|
Padding(
|
||||||
FreezerTitle(),
|
padding: EdgeInsets.symmetric(vertical: 16.0),
|
||||||
Container(height: 16.0,),
|
child: FreezerTitle(),
|
||||||
|
),
|
||||||
HomePageScreen()
|
HomePageScreen()
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,38 +141,40 @@ class _HomePageScreenState extends State<HomePageScreen> {
|
||||||
return Center(child: CircularProgressIndicator(),);
|
return Center(child: CircularProgressIndicator(),);
|
||||||
if (_error)
|
if (_error)
|
||||||
return ErrorScreen();
|
return ErrorScreen();
|
||||||
return SingleChildScrollView(
|
return ListView.builder(
|
||||||
child: Column(
|
shrinkWrap: true,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
addAutomaticKeepAlives: true,
|
||||||
children: List.generate(_homePage.sections.length, (i) {
|
physics: NeverScrollableScrollPhysics(),
|
||||||
HomePageSection section = _homePage.sections[i];
|
itemCount: _homePage.sections.length,
|
||||||
return Column(
|
itemBuilder: (context, i) {
|
||||||
mainAxisSize: MainAxisSize.min,
|
HomePageSection section = _homePage.sections[i];
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
return Column(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
Padding(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Text(
|
children: [
|
||||||
section.title,
|
Padding(
|
||||||
textAlign: TextAlign.left,
|
child: Text(
|
||||||
maxLines: 2,
|
section.title,
|
||||||
overflow: TextOverflow.ellipsis,
|
textAlign: TextAlign.left,
|
||||||
style: TextStyle(fontSize: 24.0),
|
maxLines: 2,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0)
|
style: TextStyle(fontSize: 24.0),
|
||||||
),
|
),
|
||||||
SingleChildScrollView(
|
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0)
|
||||||
scrollDirection: Axis.horizontal,
|
),
|
||||||
child: Row(
|
|
||||||
children: List.generate(section.items.length, (i) {
|
SingleChildScrollView(
|
||||||
HomePageItem item = section.items[i];
|
scrollDirection: Axis.horizontal,
|
||||||
return HomePageItemWidget(item);
|
child: Row(
|
||||||
}),
|
children: List.generate(section.items.length, (i) {
|
||||||
),
|
HomePageItem item = section.items[i];
|
||||||
|
return HomePageItemWidget(item);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
);
|
],
|
||||||
}),
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,6 +187,7 @@ class HomePageItemWidget extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case HomePageItemType.SMARTTRACKLIST:
|
case HomePageItemType.SMARTTRACKLIST:
|
||||||
return SmartTrackListTile(
|
return SmartTrackListTile(
|
||||||
|
|
|
@ -169,11 +169,11 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.fromLTRB(28, 16, 28, 0),
|
padding: EdgeInsets.fromLTRB(28, 12, 28, 4),
|
||||||
child: PlayerScreenTopRow()
|
child: PlayerScreenTopRow()
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.fromLTRB(16, 8, 16, 8),
|
padding: EdgeInsets.fromLTRB(16, 0, 16, 0),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 360,
|
height: 360,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
@ -229,7 +229,7 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
||||||
),
|
),
|
||||||
//Container(height: 8.0,),
|
//Container(height: 8.0,),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
padding: EdgeInsets.symmetric(vertical: 0, horizontal: 16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
|
import 'package:audio_service/audio_service.dart';
|
||||||
import 'package:country_pickers/country.dart';
|
import 'package:country_pickers/country.dart';
|
||||||
import 'package:country_pickers/country_picker_dialog.dart';
|
import 'package:country_pickers/country_picker_dialog.dart';
|
||||||
import 'package:filesize/filesize.dart';
|
import 'package:filesize/filesize.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
|
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:freezer/api/deezer.dart';
|
import 'package:freezer/api/deezer.dart';
|
||||||
import 'package:freezer/ui/error.dart';
|
import 'package:freezer/ui/error.dart';
|
||||||
import 'package:freezer/ui/player_bar.dart';
|
|
||||||
import 'package:language_pickers/language_pickers.dart';
|
import 'package:language_pickers/language_pickers.dart';
|
||||||
import 'package:language_pickers/languages.dart';
|
import 'package:language_pickers/languages.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
|
@ -501,6 +502,42 @@ class _GeneralSettingsState extends State<GeneralSettings> {
|
||||||
settings.save();
|
settings.save();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text('Log out', style: TextStyle(color: Colors.red),),
|
||||||
|
leading: Icon(Icons.exit_to_app),
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text('Log out'),
|
||||||
|
content: Text('Due to plugin incompatibility, login using browser is unavailable without restart.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Cancel'),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
child: Text('(ARL ONLY) Continue'),
|
||||||
|
onPressed: () {
|
||||||
|
logOut();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Log out & Exit'),
|
||||||
|
onPressed: () async {
|
||||||
|
try {AudioService.stop();} catch (e) {}
|
||||||
|
await logOut();
|
||||||
|
SystemNavigator.pop();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -239,6 +239,7 @@ class PlaylistCardTile extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SmartTrackListTile extends StatelessWidget {
|
class SmartTrackListTile extends StatelessWidget {
|
||||||
|
|
||||||
final SmartTrackList smartTrackList;
|
final SmartTrackList smartTrackList;
|
||||||
|
|
Loading…
Reference in New Issue