Merge pull request #32 from krawieck/handle-anonymous-user-profile-tab
This commit is contained in:
commit
1b732fe4f2
|
@ -17,6 +17,27 @@ class UserProfileTab extends HookWidget {
|
|||
|
||||
return Observer(
|
||||
builder: (ctx) {
|
||||
if (ctx.watch<AccountsStore>().hasNoAccount) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('No account was added.'),
|
||||
FlatButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => AccountsConfigPage()));
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text('Add account'),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
var user = ctx.watch<AccountsStore>().defaultUser;
|
||||
|
||||
return Scaffold(
|
||||
|
|
|
@ -26,8 +26,8 @@ class SettingsPage extends StatelessWidget {
|
|||
leading: Icon(Icons.person),
|
||||
title: Text('Accounts'),
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.push(MaterialPageRoute(builder: (_) => _AccountsConfig()));
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => AccountsConfigPage()));
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
|
@ -35,7 +35,7 @@ class SettingsPage extends StatelessWidget {
|
|||
title: Text('Appearance'),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => _AppearanceConfig()));
|
||||
MaterialPageRoute(builder: (_) => AppearanceConfigPage()));
|
||||
},
|
||||
)
|
||||
],
|
||||
|
@ -45,7 +45,7 @@ class SettingsPage extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class _AppearanceConfig extends StatelessWidget {
|
||||
class AppearanceConfigPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var theme = Theme.of(context);
|
||||
|
@ -84,7 +84,7 @@ class _AppearanceConfig extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class _AccountsConfig extends HookWidget {
|
||||
class AccountsConfigPage extends HookWidget {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
|
||||
|
||||
@override
|
||||
|
|
|
@ -102,6 +102,9 @@ abstract class _AccountsStore with Store {
|
|||
bool isAnonymousFor(String instanceUrl) =>
|
||||
Computed(() => users[instanceUrl].isEmpty).value;
|
||||
|
||||
@computed
|
||||
bool get hasNoAccount => users.values.every((e) => e.isEmpty);
|
||||
|
||||
/// adds a new account
|
||||
/// if it's the first account ever the account is
|
||||
/// set as default for the app
|
||||
|
@ -129,7 +132,7 @@ abstract class _AccountsStore with Store {
|
|||
// first account for this instance
|
||||
if (users[instanceUrl].isEmpty) {
|
||||
// first account ever
|
||||
if (users.values.every((e) => e.isEmpty)) {
|
||||
if (hasNoAccount) {
|
||||
setDefaultAccount(instanceUrl, userData.name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue