Make account actions more obvious
This commit is contained in:
parent
9b725d8a02
commit
ee4ef8de91
|
@ -2,13 +2,13 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
|
|
||||||
import '../hooks/stores.dart';
|
import '../hooks/stores.dart';
|
||||||
import '../l10n/l10n.dart';
|
import '../l10n/l10n.dart';
|
||||||
import '../util/goto.dart';
|
import '../util/goto.dart';
|
||||||
import '../widgets/about_tile.dart';
|
import '../widgets/about_tile.dart';
|
||||||
|
import '../widgets/bottom_modal.dart';
|
||||||
import '../widgets/radio_picker.dart';
|
import '../widgets/radio_picker.dart';
|
||||||
import 'add_account.dart';
|
import 'add_account.dart';
|
||||||
import 'add_instance.dart';
|
import 'add_instance.dart';
|
||||||
|
@ -128,6 +128,7 @@ class AccountsConfigPage extends HookWidget {
|
||||||
) ??
|
) ??
|
||||||
false) {
|
false) {
|
||||||
await accountsStore.removeInstance(instanceHost);
|
await accountsStore.removeInstance(instanceHost);
|
||||||
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,10 +152,50 @@ class AccountsConfigPage extends HookWidget {
|
||||||
),
|
),
|
||||||
) ??
|
) ??
|
||||||
false) {
|
false) {
|
||||||
return accountsStore.removeAccount(instanceHost, username);
|
await accountsStore.removeAccount(instanceHost, username);
|
||||||
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void accountActions(String instanceHost, String username) {
|
||||||
|
showBottomModal(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Column(
|
||||||
|
children: [
|
||||||
|
if (accountsStore.defaultUsernameFor(instanceHost) != username)
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.check_circle_outline),
|
||||||
|
title: const Text('Set as default'),
|
||||||
|
onTap: () {
|
||||||
|
accountsStore.setDefaultAccountFor(instanceHost, username);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.delete),
|
||||||
|
title: const Text('Remove account'),
|
||||||
|
onTap: () => removeUserDialog(instanceHost, username),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void instanceActions(String instanceHost) {
|
||||||
|
showBottomModal(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Column(
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.delete),
|
||||||
|
title: const Text('Remove instance'),
|
||||||
|
onTap: () => removeInstanceDialog(instanceHost),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -206,62 +247,30 @@ class AccountsConfigPage extends HookWidget {
|
||||||
),
|
),
|
||||||
for (final instance in accountsStore.instances) ...[
|
for (final instance in accountsStore.instances) ...[
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
Slidable(
|
ListTile(
|
||||||
actionPane: const SlidableBehindActionPane(),
|
dense: true,
|
||||||
secondaryActions: [
|
contentPadding: EdgeInsets.zero,
|
||||||
IconSlideAction(
|
onLongPress: () => instanceActions(instance),
|
||||||
onTap: () => removeInstanceDialog(instance),
|
title: _SectionHeading(instance),
|
||||||
icon: Icons.delete_sweep,
|
|
||||||
color: Colors.red,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
key: Key(instance),
|
|
||||||
// TODO: missing ripple effect
|
|
||||||
child: Container(
|
|
||||||
color: theme.scaffoldBackgroundColor,
|
|
||||||
child: ListTile(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
title: _SectionHeading(instance),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
for (final username in accountsStore.usernamesFor(instance)) ...[
|
for (final username in accountsStore.usernamesFor(instance)) ...[
|
||||||
Slidable(
|
ListTile(
|
||||||
actionPane: const SlidableBehindActionPane(),
|
trailing: username == accountsStore.defaultUsernameFor(instance)
|
||||||
key: Key('$username@$instance'),
|
? Icon(
|
||||||
secondaryActions: [
|
Icons.check_circle_outline,
|
||||||
IconSlideAction(
|
color: theme.accentColor,
|
||||||
onTap: () => removeUserDialog(instance, username),
|
)
|
||||||
icon: Icons.delete_sweep,
|
: null,
|
||||||
color: Colors.red,
|
title: Text(username),
|
||||||
),
|
onLongPress: () => accountActions(instance, username),
|
||||||
],
|
onTap: () {
|
||||||
// TODO: missing ripple effect
|
goTo(
|
||||||
child: Container(
|
context,
|
||||||
color: theme.scaffoldBackgroundColor,
|
(_) => ManageAccountPage(
|
||||||
child: ListTile(
|
instanceHost: instance,
|
||||||
trailing:
|
username: username,
|
||||||
username == accountsStore.defaultUsernameFor(instance)
|
));
|
||||||
? Icon(
|
},
|
||||||
Icons.check_circle_outline,
|
|
||||||
color: theme.accentColor,
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: Text(username),
|
|
||||||
onLongPress: () {
|
|
||||||
accountsStore.setDefaultAccountFor(instance, username);
|
|
||||||
},
|
|
||||||
onTap: () {
|
|
||||||
goTo(
|
|
||||||
context,
|
|
||||||
(_) => ManageAccountPage(
|
|
||||||
instanceHost: instance,
|
|
||||||
username: username,
|
|
||||||
));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (accountsStore.usernamesFor(instance).isEmpty)
|
if (accountsStore.usernamesFor(instance).isEmpty)
|
||||||
|
|
|
@ -263,13 +263,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
flutter_slidable:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_slidable
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.5.7"
|
|
||||||
flutter_speed_dial:
|
flutter_speed_dial:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -23,7 +23,6 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
# widgets
|
# widgets
|
||||||
flutter_speed_dial: ^1.2.5
|
flutter_speed_dial: ^1.2.5
|
||||||
flutter_slidable: ^0.5.7
|
|
||||||
photo_view: ^0.10.2
|
photo_view: ^0.10.2
|
||||||
markdown: ^4.0.0
|
markdown: ^4.0.0
|
||||||
flutter_markdown: ^0.6.1
|
flutter_markdown: ^0.6.1
|
||||||
|
|
Loading…
Reference in New Issue