|
|
|
@ -21,8 +21,9 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
final _scaffoldKey = GlobalKey<ScaffoldState>(); |
|
|
|
|
|
|
|
|
|
late GlobalOptions _globalOptions; |
|
|
|
|
late CapabilitiesBloc _capabilitiesBloc; |
|
|
|
|
late AccountsBloc _accountsBloc; |
|
|
|
|
late AppsBloc _appsBloc; |
|
|
|
|
late CapabilitiesBloc _capabilitiesBloc; |
|
|
|
|
late FirstLaunchBloc _firstLaunchBloc; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -30,10 +31,22 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
_globalOptions = Provider.of<GlobalOptions>(context, listen: false); |
|
|
|
|
_appsBloc = Provider.of<AccountsBloc>(context, listen: false).getAppsBloc(widget.account); |
|
|
|
|
_capabilitiesBloc = Provider.of<AccountsBloc>(context, listen: false).getCapabilitiesBloc(widget.account); |
|
|
|
|
_accountsBloc = Provider.of<AccountsBloc>(context, listen: false); |
|
|
|
|
_appsBloc = _accountsBloc.getAppsBloc(widget.account); |
|
|
|
|
_capabilitiesBloc = _accountsBloc.getCapabilitiesBloc(widget.account); |
|
|
|
|
_firstLaunchBloc = Provider.of<FirstLaunchBloc>(context, listen: false); |
|
|
|
|
|
|
|
|
|
_appsBloc.openNotifications.listen((final _) async { |
|
|
|
|
final notificationsAppImplementation = _appsBloc.notificationsAppImplementation.valueOrNull; |
|
|
|
|
if (notificationsAppImplementation != null) { |
|
|
|
|
await _openNotifications( |
|
|
|
|
notificationsAppImplementation.data!, |
|
|
|
|
_accountsBloc.accounts.value, |
|
|
|
|
_accountsBloc.activeAccount.value!, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
_capabilitiesBloc.capabilities.listen((final result) async { |
|
|
|
|
if (result.data != null) { |
|
|
|
|
widget.onThemeChanged(result.data!.capabilities.theming); |
|
|
|
@ -153,6 +166,34 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Future _openNotifications( |
|
|
|
|
final NotificationsApp app, |
|
|
|
|
final List<Account> accounts, |
|
|
|
|
final Account account, |
|
|
|
|
) async { |
|
|
|
|
await Navigator.of(context).push( |
|
|
|
|
MaterialPageRoute( |
|
|
|
|
builder: (final context) => Scaffold( |
|
|
|
|
appBar: AppBar( |
|
|
|
|
title: Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text(app.name(context)), |
|
|
|
|
if (accounts.length > 1) ...[ |
|
|
|
|
Text( |
|
|
|
|
account.client.humanReadableID, |
|
|
|
|
style: Theme.of(context).textTheme.bodySmall, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
body: app.buildPage(context, _appsBloc), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
|
_capabilitiesBloc.dispose(); |
|
|
|
@ -160,9 +201,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(final BuildContext context) { |
|
|
|
|
final accountsBloc = Provider.of<AccountsBloc>(context, listen: false); |
|
|
|
|
return ResultBuilder<CapabilitiesBloc, Capabilities>( |
|
|
|
|
Widget build(final BuildContext context) => ResultBuilder<CapabilitiesBloc, Capabilities>( |
|
|
|
|
stream: _capabilitiesBloc.capabilities, |
|
|
|
|
builder: (final context, final capabilities) => ResultBuilder<AppsBloc, List<AppImplementation>>( |
|
|
|
|
stream: _appsBloc.appImplementations, |
|
|
|
@ -175,7 +214,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
final activeAppIDSnapshot, |
|
|
|
|
) => |
|
|
|
|
StreamBuilder<List<Account>>( |
|
|
|
|
stream: accountsBloc.accounts, |
|
|
|
|
stream: _accountsBloc.accounts, |
|
|
|
|
builder: ( |
|
|
|
|
final context, |
|
|
|
|
final accountsSnapshot, |
|
|
|
@ -227,7 +266,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
message: account.client.humanReadableID, |
|
|
|
|
child: IconButton( |
|
|
|
|
onPressed: () { |
|
|
|
|
accountsBloc.setActiveAccount(account); |
|
|
|
|
_accountsBloc.setActiveAccount(account); |
|
|
|
|
}, |
|
|
|
|
icon: IntrinsicHeight( |
|
|
|
|
child: AccountAvatar( |
|
|
|
@ -289,7 +328,8 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
child: DropdownButton<String>( |
|
|
|
|
isExpanded: true, |
|
|
|
|
dropdownColor: Theme.of(context).colorScheme.primary, |
|
|
|
|
iconEnabledColor: Theme.of(context).colorScheme.onBackground, |
|
|
|
|
iconEnabledColor: |
|
|
|
|
Theme.of(context).colorScheme.onBackground, |
|
|
|
|
value: widget.account.id, |
|
|
|
|
items: accounts |
|
|
|
|
.map<DropdownMenuItem<String>>( |
|
|
|
@ -307,7 +347,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
onChanged: (final id) { |
|
|
|
|
for (final account in accounts) { |
|
|
|
|
if (account.id == id) { |
|
|
|
|
accountsBloc.setActiveAccount(account); |
|
|
|
|
_accountsBloc.setActiveAccount(account); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -506,27 +546,10 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
height: kAvatarSize * 2 / 3, |
|
|
|
|
), |
|
|
|
|
onPressed: () async { |
|
|
|
|
await Navigator.of(context).push( |
|
|
|
|
MaterialPageRoute( |
|
|
|
|
builder: (final context) => Scaffold( |
|
|
|
|
appBar: AppBar( |
|
|
|
|
title: Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text(notificationsAppImplementation.data!.name(context)), |
|
|
|
|
if (accounts.length > 1) ...[ |
|
|
|
|
Text( |
|
|
|
|
account.client.humanReadableID, |
|
|
|
|
style: Theme.of(context).textTheme.bodySmall, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
body: notificationsAppImplementation.data! |
|
|
|
|
.buildPage(context, _appsBloc), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
await _openNotifications( |
|
|
|
|
notificationsAppImplementation.data!, |
|
|
|
|
accounts, |
|
|
|
|
account, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
@ -543,7 +566,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
await Navigator.of(context).push( |
|
|
|
|
MaterialPageRoute( |
|
|
|
|
builder: (final context) => AccountSettingsPage( |
|
|
|
|
bloc: accountsBloc, |
|
|
|
|
bloc: _accountsBloc, |
|
|
|
|
account: account, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -569,7 +592,8 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
Expanded( |
|
|
|
|
child: Center( |
|
|
|
|
child: Text( |
|
|
|
|
AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound, |
|
|
|
|
AppLocalizations.of(context) |
|
|
|
|
.errorNoCompatibleNextcloudAppsFound, |
|
|
|
|
textAlign: TextAlign.center, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -605,5 +629,4 @@ class _HomePageState extends State<HomePage> {
|
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|