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