Browse Source

refactor(neon,neon_files): Adjust to generated specs

pull/465/head
jld3103 1 year ago
parent
commit
e222ac5593
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/neon/neon/lib/src/app.dart
  2. 2
      packages/neon/neon/lib/src/blocs/accounts.dart
  3. 11
      packages/neon/neon/lib/src/blocs/apps.dart
  4. 13
      packages/neon/neon/lib/src/blocs/capabilities.dart
  5. 2
      packages/neon/neon/lib/src/blocs/login_check_account.dart
  6. 4
      packages/neon/neon/lib/src/blocs/login_check_server_status.dart
  7. 14
      packages/neon/neon/lib/src/blocs/login_flow.dart
  8. 5
      packages/neon/neon/lib/src/blocs/user_details.dart
  9. 23
      packages/neon/neon/lib/src/blocs/user_statuses.dart
  10. 1
      packages/neon/neon/lib/src/models/account.dart
  11. 2
      packages/neon/neon/lib/src/models/push_notification.dart
  12. 2
      packages/neon/neon/lib/src/models/push_notification.g.dart
  13. 8
      packages/neon/neon/lib/src/pages/account_settings.dart
  14. 4
      packages/neon/neon/lib/src/pages/login_check_server_status.dart
  15. 12
      packages/neon/neon/lib/src/theme/colors.dart
  16. 4
      packages/neon/neon/lib/src/theme/theme.dart
  17. 28
      packages/neon/neon/lib/src/widgets/drawer.dart
  18. 16
      packages/neon/neon/lib/src/widgets/user_avatar.dart
  19. 2
      packages/neon/neon_files/lib/widgets/file_preview.dart
  20. 4
      packages/neon/neon_news/lib/blocs/articles.dart

4
packages/neon/neon/lib/src/app.dart

@ -8,7 +8,6 @@ import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:neon/l10n/localizations.dart'; import 'package:neon/l10n/localizations.dart';
import 'package:neon/src/bloc/result_builder.dart'; import 'package:neon/src/bloc/result_builder.dart';
import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/blocs/capabilities.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
import 'package:neon/src/models/app_ids.dart'; import 'package:neon/src/models/app_ids.dart';
import 'package:neon/src/models/app_implementation.dart'; import 'package:neon/src/models/app_implementation.dart';
@ -22,6 +21,7 @@ import 'package:neon/src/utils/global.dart';
import 'package:neon/src/utils/global_options.dart'; import 'package:neon/src/utils/global_options.dart';
import 'package:neon/src/utils/localizations.dart'; import 'package:neon/src/utils/localizations.dart';
import 'package:neon/src/utils/push_utils.dart'; import 'package:neon/src/utils/push_utils.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:quick_actions/quick_actions.dart'; import 'package:quick_actions/quick_actions.dart';
import 'package:tray_manager/tray_manager.dart' as tray; import 'package:tray_manager/tray_manager.dart' as tray;
@ -285,7 +285,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
stream: _accountsBloc.activeAccount, stream: _accountsBloc.activeAccount,
builder: (final context, final activeAccountSnapshot) { builder: (final context, final activeAccountSnapshot) {
FlutterNativeSplash.remove(); FlutterNativeSplash.remove();
return ResultBuilder<Capabilities?>.behaviorSubject( return ResultBuilder<CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data?>.behaviorSubject(
stream: activeAccountSnapshot.hasData stream: activeAccountSnapshot.hasData
? _accountsBloc.getCapabilitiesBlocFor(activeAccountSnapshot.data!).capabilities ? _accountsBloc.getCapabilitiesBlocFor(activeAccountSnapshot.data!).capabilities
: null, : null,

2
packages/neon/neon/lib/src/blocs/accounts.dart

@ -157,7 +157,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
unawaited(() async { unawaited(() async {
try { try {
await account.client.core.deleteAppPassword(); await account.client.core.appPassword.deleteAppPassword();
} catch (e, s) { } catch (e, s) {
debugPrint(e.toString()); debugPrint(e.toString());
debugPrint(s.toString()); debugPrint(s.toString());

11
packages/neon/neon/lib/src/blocs/apps.dart

@ -16,8 +16,6 @@ import 'package:nextcloud/nextcloud.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
typedef NextcloudApp = CoreNavigationApps_Ocs_Data;
abstract class AppsBlocEvents { abstract class AppsBlocEvents {
/// Sets the active app using the [appID]. /// Sets the active app using the [appID].
/// ///
@ -27,7 +25,7 @@ abstract class AppsBlocEvents {
} }
abstract class AppsBlocStates { abstract class AppsBlocStates {
BehaviorSubject<Result<List<NextcloudApp>>> get apps; BehaviorSubject<Result<List<CoreNavigationEntry>>> get apps;
BehaviorSubject<Result<Iterable<AppImplementation>>> get appImplementations; BehaviorSubject<Result<Iterable<AppImplementation>>> get appImplementations;
@ -181,7 +179,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
BehaviorSubject<Result<Iterable<AppImplementation>>>(); BehaviorSubject<Result<Iterable<AppImplementation>>>();
@override @override
BehaviorSubject<Result<List<NextcloudApp>>> apps = BehaviorSubject<Result<List<NextcloudApp>>>(); BehaviorSubject<Result<List<CoreNavigationEntry>>> apps = BehaviorSubject<Result<List<CoreNavigationEntry>>>();
@override @override
BehaviorSubject<Result<NotificationsAppInterface?>> notificationsAppImplementation = BehaviorSubject<Result<NotificationsAppInterface?>> notificationsAppImplementation =
@ -195,11 +193,12 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
@override @override
Future refresh() async { Future refresh() async {
await _requestManager.wrapNextcloud<List<NextcloudApp>, CoreNavigationApps>( await _requestManager
.wrapNextcloud<List<CoreNavigationEntry>, CoreNavigationGetAppsNavigationResponse200ApplicationJson>(
_account.id, _account.id,
'apps-apps', 'apps-apps',
apps, apps,
() async => _account.client.core.getNavigationApps(), () async => _account.client.core.navigation.getAppsNavigation(),
(final response) => response.ocs.data.toList(), (final response) => response.ocs.data.toList(),
); );
} }

13
packages/neon/neon/lib/src/blocs/capabilities.dart

@ -8,13 +8,10 @@ import 'package:neon/src/utils/request_manager.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
typedef Capabilities = CoreServerCapabilities_Ocs_Data;
typedef NextcloudTheme = CoreServerCapabilities_Ocs_Data_Capabilities_Theming;
abstract class CapabilitiesBlocEvents {} abstract class CapabilitiesBlocEvents {}
abstract class CapabilitiesBlocStates { abstract class CapabilitiesBlocStates {
BehaviorSubject<Result<Capabilities>> get capabilities; BehaviorSubject<Result<CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data>> get capabilities;
} }
@internal @internal
@ -36,15 +33,17 @@ class CapabilitiesBloc extends InteractiveBloc implements CapabilitiesBlocEvents
} }
@override @override
BehaviorSubject<Result<Capabilities>> capabilities = BehaviorSubject<Result<Capabilities>>(); BehaviorSubject<Result<CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data>> capabilities =
BehaviorSubject<Result<CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data>>();
@override @override
Future refresh() async { Future refresh() async {
await _requestManager.wrapNextcloud<CoreServerCapabilities_Ocs_Data, CoreServerCapabilities>( await _requestManager.wrapNextcloud<CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data,
CoreOcsGetCapabilitiesResponse200ApplicationJson>(
_account.id, _account.id,
'capabilities', 'capabilities',
capabilities, capabilities,
() async => _account.client.core.getCapabilities(), () async => _account.client.core.ocs.getCapabilities(),
(final response) => response.ocs.data, (final response) => response.ocs.data,
); );
} }

2
packages/neon/neon/lib/src/blocs/login_check_account.dart

@ -49,7 +49,7 @@ class LoginCheckAccountBloc extends InteractiveBloc
userAgentOverride: neonUserAgent, userAgentOverride: neonUserAgent,
); );
final response = await client.provisioningApi.getCurrentUser(); final response = await client.provisioningApi.users.getCurrentUser();
final account = Account( final account = Account(
serverURL: serverURL, serverURL: serverURL,

4
packages/neon/neon/lib/src/blocs/login_check_server_status.dart

@ -11,7 +11,7 @@ abstract interface class LoginCheckServerStatusBlocEvents {}
abstract interface class LoginCheckServerStatusBlocStates { abstract interface class LoginCheckServerStatusBlocStates {
/// Contains the current server connection state /// Contains the current server connection state
BehaviorSubject<Result<CoreServerStatus>> get state; BehaviorSubject<Result<CoreStatus>> get state;
} }
class LoginCheckServerStatusBloc extends InteractiveBloc class LoginCheckServerStatusBloc extends InteractiveBloc
@ -28,7 +28,7 @@ class LoginCheckServerStatusBloc extends InteractiveBloc
} }
@override @override
BehaviorSubject<Result<CoreServerStatus>> state = BehaviorSubject(); BehaviorSubject<Result<CoreStatus>> state = BehaviorSubject();
@override @override
Future refresh() async { Future refresh() async {

14
packages/neon/neon/lib/src/blocs/login_flow.dart

@ -10,9 +10,9 @@ import 'package:rxdart/rxdart.dart';
abstract class LoginFlowBlocEvents {} abstract class LoginFlowBlocEvents {}
abstract class LoginFlowBlocStates { abstract class LoginFlowBlocStates {
BehaviorSubject<Result<CoreLoginFlowInit>> get init; BehaviorSubject<Result<CoreLoginFlowV2>> get init;
Stream<CoreLoginFlowResult> get result; Stream<CoreLoginFlowV2Credentials> get result;
} }
class LoginFlowBloc extends InteractiveBloc implements LoginFlowBlocEvents, LoginFlowBlocStates { class LoginFlowBloc extends InteractiveBloc implements LoginFlowBlocEvents, LoginFlowBlocStates {
@ -25,7 +25,7 @@ class LoginFlowBloc extends InteractiveBloc implements LoginFlowBlocEvents, Logi
serverURL, serverURL,
userAgentOverride: neonUserAgent, userAgentOverride: neonUserAgent,
); );
final _resultController = StreamController<CoreLoginFlowResult>(); final _resultController = StreamController<CoreLoginFlowV2Credentials>();
Timer? _pollTimer; Timer? _pollTimer;
@ -37,23 +37,23 @@ class LoginFlowBloc extends InteractiveBloc implements LoginFlowBlocEvents, Logi
} }
@override @override
BehaviorSubject<Result<CoreLoginFlowInit>> init = BehaviorSubject<Result<CoreLoginFlowInit>>(); BehaviorSubject<Result<CoreLoginFlowV2>> init = BehaviorSubject<Result<CoreLoginFlowV2>>();
@override @override
late Stream<CoreLoginFlowResult> result = _resultController.stream.asBroadcastStream(); late Stream<CoreLoginFlowV2Credentials> result = _resultController.stream.asBroadcastStream();
@override @override
Future refresh() async { Future refresh() async {
try { try {
init.add(Result.loading()); init.add(Result.loading());
final initResponse = await _client.core.initLoginFlow(); final initResponse = await _client.core.clientFlowLoginV2.init();
init.add(Result.success(initResponse)); init.add(Result.success(initResponse));
_cancelPollTimer(); _cancelPollTimer();
_pollTimer = Timer.periodic(const Duration(seconds: 1), (final _) async { _pollTimer = Timer.periodic(const Duration(seconds: 1), (final _) async {
try { try {
final resultResponse = await _client.core.getLoginFlowResult(token: initResponse.poll.token); final resultResponse = await _client.core.clientFlowLoginV2.poll(token: initResponse.poll.token);
_cancelPollTimer(); _cancelPollTimer();
_resultController.add(resultResponse); _resultController.add(resultResponse);
} catch (e, s) { } catch (e, s) {

5
packages/neon/neon/lib/src/blocs/user_details.dart

@ -38,11 +38,12 @@ class UserDetailsBloc extends InteractiveBloc implements UserDetailsBlocEvents,
@override @override
Future refresh() async { Future refresh() async {
await _requestManager.wrapNextcloud<ProvisioningApiUserDetails, ProvisioningApiUser>( await _requestManager
.wrapNextcloud<ProvisioningApiUserDetails, ProvisioningApiUsersGetCurrentUserResponse200ApplicationJson>(
_account.id, _account.id,
'user-details', 'user-details',
userDetails, userDetails,
() async => _account.client.provisioningApi.getCurrentUser(), () async => _account.client.provisioningApi.users.getCurrentUser(),
(final response) => response.ocs.data, (final response) => response.ocs.data,
); );
} }

23
packages/neon/neon/lib/src/blocs/user_statuses.dart

@ -16,7 +16,7 @@ abstract class UserStatusesBlocEvents {
} }
abstract class UserStatusesBlocStates { abstract class UserStatusesBlocStates {
BehaviorSubject<Map<String, Result<UserStatusPublicStatus?>>> get statuses; BehaviorSubject<Map<String, Result<UserStatusPublic?>>> get statuses;
} }
@internal @internal
@ -41,8 +41,8 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents
} }
@override @override
BehaviorSubject<Map<String, Result<UserStatusPublicStatus?>>> statuses = BehaviorSubject<Map<String, Result<UserStatusPublic?>>> statuses =
BehaviorSubject<Map<String, Result<UserStatusPublicStatus?>>>(); BehaviorSubject<Map<String, Result<UserStatusPublic?>>>();
@override @override
Future refresh() async { Future refresh() async {
@ -60,17 +60,17 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents
try { try {
_updateStatus(username, Result.loading()); _updateStatus(username, Result.loading());
UserStatusPublicStatus? data; UserStatusPublic? data;
if (_account.username == username) { if (_account.username == username) {
final isAway = final isAway =
_platform.canUseWindowManager && (!(await windowManager.isFocused()) || !(await windowManager.isVisible())); _platform.canUseWindowManager && (!(await windowManager.isFocused()) || !(await windowManager.isVisible()));
final response = await _account.client.userStatus.heartbeat( final response = await _account.client.userStatus.heartbeat.heartbeat(
status: isAway ? UserStatusType.away : UserStatusType.online, status: isAway ? 'away' : 'online',
); );
data = response.ocs.data.status?.publicStatus; data = response.ocs.data.public;
} else { } else {
final response = await _account.client.userStatus.getPublicStatus(userId: username); final response = await _account.client.userStatus.statuses.find(userId: username);
data = response.ocs.data.publicStatus; data = response.ocs.data;
} }
_updateStatus(username, Result.success(data)); _updateStatus(username, Result.success(data));
@ -85,10 +85,9 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents
} }
} }
Map<String, Result<UserStatusPublicStatus?>> get _statuses => Map<String, Result<UserStatusPublic?>> get _statuses => statuses.valueOrNull ?? <String, Result<UserStatusPublic?>>{};
statuses.valueOrNull ?? <String, Result<UserStatusPublicStatus?>>{};
void _updateStatus(final String username, final Result<UserStatusPublicStatus?> result) { void _updateStatus(final String username, final Result<UserStatusPublic?> result) {
statuses.add({ statuses.add({
..._statuses, ..._statuses,
username: result, username: result,

1
packages/neon/neon/lib/src/models/account.dart

@ -39,6 +39,7 @@ class Account implements Credentials {
); );
factory Account.fromJson(final Map<String, dynamic> json) => _$AccountFromJson(json); factory Account.fromJson(final Map<String, dynamic> json) => _$AccountFromJson(json);
Map<String, dynamic> toJson() => _$AccountToJson(this); Map<String, dynamic> toJson() => _$AccountToJson(this);
@override @override

2
packages/neon/neon/lib/src/models/push_notification.dart

@ -24,5 +24,5 @@ class PushNotification {
final String type; final String type;
final NotificationsNotificationDecryptedSubject subject; final NotificationsDecryptedSubject subject;
} }

2
packages/neon/neon/lib/src/models/push_notification.g.dart

@ -10,7 +10,7 @@ PushNotification _$PushNotificationFromJson(Map<String, dynamic> json) => PushNo
accountID: json['accountID'] as String, accountID: json['accountID'] as String,
priority: json['priority'] as String, priority: json['priority'] as String,
type: json['type'] as String, type: json['type'] as String,
subject: NotificationsNotificationDecryptedSubject.fromJson(json['subject'] as Map<String, dynamic>), subject: NotificationsDecryptedSubject.fromJson(json['subject'] as Map<String, dynamic>),
); );
Map<String, dynamic> _$PushNotificationToJson(PushNotification instance) => <String, dynamic>{ Map<String, dynamic> _$PushNotificationToJson(PushNotification instance) => <String, dynamic>{

8
packages/neon/neon/lib/src/pages/account_settings.dart

@ -88,7 +88,7 @@ class AccountSettingsPage extends StatelessWidget {
children: [ children: [
if (userDetails.hasData) ...[ if (userDetails.hasData) ...[
LinearProgressIndicator( LinearProgressIndicator(
value: userDetails.requireData.quota.relative / 100, value: (userDetails.requireData.quota.relative ?? 0) / 100,
backgroundColor: Theme.of(context).colorScheme.primary.withOpacity(0.3), backgroundColor: Theme.of(context).colorScheme.primary.withOpacity(0.3),
), ),
const SizedBox( const SizedBox(
@ -96,9 +96,9 @@ class AccountSettingsPage extends StatelessWidget {
), ),
Text( Text(
AppLocalizations.of(context).accountOptionsQuotaUsedOf( AppLocalizations.of(context).accountOptionsQuotaUsedOf(
filesize(userDetails.requireData.quota.used, 1), filesize(userDetails.requireData.quota.used ?? 0, 1),
filesize(userDetails.requireData.quota.total, 1), filesize(userDetails.requireData.quota.total ?? 0, 1),
userDetails.requireData.quota.relative.toString(), (userDetails.requireData.quota.relative ?? 0).toString(),
), ),
), ),
], ],

4
packages/neon/neon/lib/src/pages/login_check_server_status.dart

@ -103,7 +103,7 @@ class _LoginCheckServerStatusPageState extends State<LoginCheckServerStatusPage>
} }
} }
Widget _buildServerVersionTile(final Result<CoreServerStatus> result) { Widget _buildServerVersionTile(final Result<CoreStatus> result) {
if (result.hasError) { if (result.hasError) {
return NeonValidationTile( return NeonValidationTile(
title: AppLocalizations.of(context).loginCheckingServerVersion, title: AppLocalizations.of(context).loginCheckingServerVersion,
@ -131,7 +131,7 @@ class _LoginCheckServerStatusPageState extends State<LoginCheckServerStatusPage>
); );
} }
Widget _buildMaintenanceModeTile(final Result<CoreServerStatus> result) { Widget _buildMaintenanceModeTile(final Result<CoreStatus> result) {
if (result.hasError) { if (result.hasError) {
return NeonValidationTile( return NeonValidationTile(
title: AppLocalizations.of(context).loginCheckingMaintenanceMode, title: AppLocalizations.of(context).loginCheckingMaintenanceMode,

12
packages/neon/neon/lib/src/theme/colors.dart

@ -29,13 +29,13 @@ abstract final class NcColors {
static const Color accept = Colors.green; static const Color accept = Colors.green;
} }
/// [UserStatusType] color mapping. /// [UserStatusPublic] status color mapping.
extension UserStatusTypeColors on UserStatusType { extension UserStatusTypeColors on UserStatusPublic {
/// The color for the user status. /// The color for the user status.
Color? get color => switch (this) { Color? get color => switch (status) {
UserStatusType.online => const Color(0xFF49B382), 'online' => const Color(0xFF49B382),
UserStatusType.away => const Color(0xFFF4A331), 'away' => const Color(0xFFF4A331),
UserStatusType.dnd => const Color(0xFFED484C), 'dnd' => const Color(0xFFED484C),
_ => null, _ => null,
}; };
} }

4
packages/neon/neon/lib/src/theme/theme.dart

@ -16,14 +16,14 @@ class AppTheme {
this.appThemes, this.appThemes,
}) : keepOriginalAccentColor = nextcloudTheme == null || keepOriginalAccentColor; }) : keepOriginalAccentColor = nextcloudTheme == null || keepOriginalAccentColor;
final CoreServerCapabilities_Ocs_Data_Capabilities_Theming? nextcloudTheme; final CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data_Capabilities_Theming? nextcloudTheme;
final bool keepOriginalAccentColor; final bool keepOriginalAccentColor;
final bool oledAsDark; final bool oledAsDark;
final Iterable<ThemeExtension>? appThemes; final Iterable<ThemeExtension>? appThemes;
final NeonTheme neonTheme; final NeonTheme neonTheme;
ColorScheme _buildColorScheme(final Brightness brightness) { ColorScheme _buildColorScheme(final Brightness brightness) {
final primary = nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color!) : neonTheme.colorScheme.primary; final primary = nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color) : neonTheme.colorScheme.primary;
final keepOriginalAccentColorOverride = keepOriginalAccentColor ? primary : null; final keepOriginalAccentColorOverride = keepOriginalAccentColor ? primary : null;
final oledBackgroundOverride = oledAsDark && brightness == Brightness.dark ? NcColors.oledBackground : null; final oledBackgroundOverride = oledAsDark && brightness == Brightness.dark ? NcColors.oledBackground : null;

28
packages/neon/neon/lib/src/widgets/drawer.dart

@ -6,13 +6,13 @@ import 'package:neon/l10n/localizations.dart';
import 'package:neon/src/bloc/result_builder.dart'; import 'package:neon/src/bloc/result_builder.dart';
import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/blocs/apps.dart'; import 'package:neon/src/blocs/apps.dart';
import 'package:neon/src/blocs/capabilities.dart';
import 'package:neon/src/models/app_implementation.dart'; import 'package:neon/src/models/app_implementation.dart';
import 'package:neon/src/router.dart'; import 'package:neon/src/router.dart';
import 'package:neon/src/widgets/cached_image.dart'; import 'package:neon/src/widgets/cached_image.dart';
import 'package:neon/src/widgets/drawer_destination.dart'; import 'package:neon/src/widgets/drawer_destination.dart';
import 'package:neon/src/widgets/exception.dart'; import 'package:neon/src/widgets/exception.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart'; import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:nextcloud/nextcloud.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@internal @internal
@ -121,7 +121,7 @@ class NeonDrawerHeader extends StatelessWidget {
final accountsBloc = Provider.of<AccountsBloc>(context, listen: false); final accountsBloc = Provider.of<AccountsBloc>(context, listen: false);
final capabilitiesBloc = accountsBloc.activeCapabilitiesBloc; final capabilitiesBloc = accountsBloc.activeCapabilitiesBloc;
final branding = ResultBuilder<Capabilities>.behaviorSubject( final branding = ResultBuilder<CoreOcsGetCapabilitiesResponse200ApplicationJson_Ocs_Data>.behaviorSubject(
stream: capabilitiesBloc.capabilities, stream: capabilitiesBloc.capabilities,
builder: (final context, final capabilities) { builder: (final context, final capabilities) {
if (!capabilities.hasData) { if (!capabilities.hasData) {
@ -147,21 +147,17 @@ class NeonDrawerHeader extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
if (theme.name != null) ...[ Text(
Text( theme.name,
theme.name!, style: DefaultTextStyle.of(context).style.copyWith(
style: DefaultTextStyle.of(context).style.copyWith( color: Theme.of(context).appBarTheme.foregroundColor,
color: Theme.of(context).appBarTheme.foregroundColor, ),
), ),
Flexible(
child: NeonCachedImage.url(
url: theme.logo,
), ),
], ),
if (theme.logo != null) ...[
Flexible(
child: NeonCachedImage.url(
url: theme.logo!,
),
),
],
], ],
); );
}, },

16
packages/neon/neon/lib/src/widgets/user_avatar.dart

@ -68,22 +68,24 @@ class _UserAvatarState extends State<NeonUserAvatar> {
cacheKey: '${widget.account.id}-avatar-${widget.username}-$brightness$pixelSize', cacheKey: '${widget.account.id}-avatar-${widget.username}-$brightness$pixelSize',
getImage: () async { getImage: () async {
if (brightness == Brightness.dark) { if (brightness == Brightness.dark) {
return widget.account.client.core.getDarkAvatar( return (await widget.account.client.core.avatar.getAvatarDark(
userId: widget.username, userId: widget.username,
size: pixelSize, size: pixelSize,
); ))
.data;
} else { } else {
return widget.account.client.core.getAvatar( return (await widget.account.client.core.avatar.getAvatar(
userId: widget.username, userId: widget.username,
size: pixelSize, size: pixelSize,
); ))
.data;
} }
}, },
), ),
), ),
), ),
if (widget.showStatus) ...[ if (widget.showStatus) ...[
ResultBuilder<UserStatusPublicStatus?>( ResultBuilder<UserStatusPublic?>(
stream: _userStatusBloc.statuses.mapNotNull((final statuses) => statuses[widget.username]), stream: _userStatusBloc.statuses.mapNotNull((final statuses) => statuses[widget.username]),
builder: _userStatusIconBuilder, builder: _userStatusIconBuilder,
), ),
@ -93,7 +95,7 @@ class _UserAvatarState extends State<NeonUserAvatar> {
}, },
); );
Widget _userStatusIconBuilder(final BuildContext context, final Result<UserStatusPublicStatus?> result) { Widget _userStatusIconBuilder(final BuildContext context, final Result<UserStatusPublic?> result) {
final hasEmoji = result.data?.icon != null; final hasEmoji = result.data?.icon != null;
final scaledSize = size / (hasEmoji ? 2 : 3); final scaledSize = size / (hasEmoji ? 2 : 3);
@ -120,7 +122,7 @@ class _UserAvatarState extends State<NeonUserAvatar> {
} else if (result.hasData) { } else if (result.hasData) {
decoration = BoxDecoration( decoration = BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: result.data!.status.color, color: result.data!.color,
); );
} }

2
packages/neon/neon_files/lib/widgets/file_preview.dart

@ -103,7 +103,7 @@ class FilePreviewImage extends NeonCachedImage {
required final int width, required final int width,
required final int height, required final int height,
}) : super.custom( }) : super.custom(
getImage: () async => account.client.core.getPreview( getImage: () async => account.client.core.preview.getPreview(
file: path, file: path,
x: width, x: width,
y: height, y: height,

4
packages/neon/neon_news/lib/blocs/articles.dart

@ -127,10 +127,10 @@ class NewsArticlesBloc extends InteractiveBloc implements NewsArticlesBlocEvents
await requestManager.wrapNextcloud<List<NewsArticle>, NewsListArticles>( await requestManager.wrapNextcloud<List<NewsArticle>, NewsListArticles>(
account.id, account.id,
'news-articles-${type.code}-$id-$getRead', 'news-articles-${type.index}-$id-$getRead',
articles, articles,
() async => account.client.news.listArticles( () async => account.client.news.listArticles(
type: type.code, type: type.index,
id: id ?? 0, id: id ?? 0,
getRead: getRead ?? true ? 1 : 0, getRead: getRead ?? true ? 1 : 0,
), ),

Loading…
Cancel
Save