Skip to content

Commit

Permalink
New option displayMode in the config file #3247
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Jan 24, 2025
1 parent 97ff8f8 commit b725ba4
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Oidc4vcSettingMenuView extends StatelessWidget {
const PushAuthorizationRequesWidget(),
const StatusListCachingWidget(),
const DPopSupoprtWidget(),
const DisplayModeWidget(),
DrawerItem(
title: 'Wallet metadata for issuers',
onTap: () {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:altme/dashboard/dashboard.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class DisplayModeWidget extends StatelessWidget {
const DisplayModeWidget({super.key});

@override
Widget build(BuildContext context) {
return BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return OptionContainer(
title: 'Display Mode',
subtitle:
// ignore: lines_longer_than_80_chars
'When activated, the wallet display only VC attributes having a display claim in the issuer metadata',
body: Switch(
onChanged: (value) async {
await context.read<ProfileCubit>().updateProfileSetting(
displayMode: value,
);
},
value: state.model.profileSetting.selfSovereignIdentityOptions
.customOidc4vcProfile.displayMode,
activeColor: Theme.of(context).colorScheme.primary,
),
);
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export 'client_authentication_widget.dart';
export 'client_type_widget.dart';
export 'cryptograhic_holder_binding.dart';
export 'did_key_type_widget.dart';
export 'display_mode_widget.dart';
export 'dpop_support_widget.dart';
export 'oidc4vc_draft_type_widget.dart';
export 'oidc4vp_draft_type_widget.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ class EmailPassWidget extends StatelessWidget {
context.read<ProfileCubit>().state.model.isDeveloperMode,
selectedClaimsKeyIds: <SelectedClaimsKeyIds>[],
onPressed: null,
displayMode: context
.read<ProfileCubit>()
.state
.model
.profileSetting
.selfSovereignIdentityOptions
.customOidc4vcProfile
.displayMode,
).buildMap;

final email = mapToDisplay['Email'];
Expand Down
2 changes: 2 additions & 0 deletions lib/dashboard/profile/cubit/profile_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ class ProfileCubit extends Cubit<ProfileState> {
bool? statusListCaching,
bool? displayNotification,
bool? dpopSupport,
bool? displayMode,
}) async {
final profileModel = state.model.copyWith(
profileSetting: state.model.profileSetting.copyWith(
Expand Down Expand Up @@ -481,6 +482,7 @@ class ProfileCubit extends Cubit<ProfileState> {
statusListCache: statusListCaching,
dpopSupport: dpopSupport,
formatsSupported: formatsSupported,
displayMode: displayMode,
),
),
),
Expand Down
4 changes: 4 additions & 0 deletions lib/dashboard/profile/models/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ProfileModel extends Equatable {
vcFormatType: VCFormatType.jwtVc,
proofType: ProofType.jwt,
formatsSupported: const [VCFormatType.jwtVc],
displayMode: false,
),
),
settingsMenu: SettingsMenu.initial(),
Expand Down Expand Up @@ -171,6 +172,7 @@ class ProfileModel extends Equatable {
VCFormatType.jwtVcJsonLd,
VCFormatType.vcSdJWT,
],
displayMode: false,
),
),
settingsMenu: SettingsMenu.initial(),
Expand Down Expand Up @@ -248,6 +250,7 @@ class ProfileModel extends Equatable {
VCFormatType.vcSdJWT,
VCFormatType.ldpVc,
],
displayMode: false,
),
),
settingsMenu: SettingsMenu.initial(),
Expand Down Expand Up @@ -333,6 +336,7 @@ class ProfileModel extends Equatable {
VCFormatType.jwtVcJsonLd,
VCFormatType.vcSdJWT,
],
displayMode: false,
),
),
settingsMenu: SettingsMenu.initial(),
Expand Down
6 changes: 6 additions & 0 deletions lib/dashboard/profile/models/profile_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ class CustomOidc4VcProfile extends Equatable {
this.statusListCache = true,
this.dpopSupport = false,
this.formatsSupported = const [],
this.displayMode = true,
});

factory CustomOidc4VcProfile.initial() => CustomOidc4VcProfile(
Expand All @@ -725,6 +726,7 @@ class CustomOidc4VcProfile extends Equatable {
clientType: ClientType.did,
clientId: Parameters.clientId,
clientSecret: randomString(12),
displayMode: false,
);

factory CustomOidc4VcProfile.fromJson(Map<String, dynamic> json) {
Expand Down Expand Up @@ -761,6 +763,7 @@ class CustomOidc4VcProfile extends Equatable {
final List<VCFormatType>? formatsSupported;
final ProofType proofType;
final bool dpopSupport;
final bool displayMode;

Map<String, dynamic> toJson() => _$CustomOidc4VcProfileToJson(this);

Expand All @@ -784,6 +787,7 @@ class CustomOidc4VcProfile extends Equatable {
List<VCFormatType>? formatsSupported,
ProofType? proofType,
bool? dpopSupport,
bool? displayMode,
}) =>
CustomOidc4VcProfile(
clientAuthentication: clientAuthentication ?? this.clientAuthentication,
Expand All @@ -807,6 +811,7 @@ class CustomOidc4VcProfile extends Equatable {
proofType: proofType ?? this.proofType,
dpopSupport: dpopSupport ?? this.dpopSupport,
formatsSupported: formatsSupported ?? this.formatsSupported,
displayMode: displayMode ?? this.displayMode,
);

@override
Expand All @@ -830,6 +835,7 @@ class CustomOidc4VcProfile extends Equatable {
formatsSupported,
proofType,
dpopSupport,
displayMode,
];
}

Expand Down
2 changes: 2 additions & 0 deletions lib/dashboard/profile/models/profile_setting.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SelectiveDisclosureDisplayMap {
required this.limitDisclosure,
required this.filters,
required this.isDeveloperMode,
required this.displayMode,
this.claims,
this.parentKeyId,
required this.selectedClaimsKeyIds,
Expand All @@ -32,6 +33,7 @@ class SelectiveDisclosureDisplayMap {
final String? parentKeyId;
final Map<String, dynamic> filters;
final List<SelectedClaimsKeyIds> selectedClaimsKeyIds;
final bool displayMode;
final void Function(
String?,
String,
Expand All @@ -54,7 +56,7 @@ class SelectiveDisclosureDisplayMap {
if (mapValue is! Map<String, dynamic>) return;

final display = getDisplay(mapValue, languageCode);

if (displayMode && display == null && !isPresentation) return;
title =
display?['name'].toString() ?? '${Parameters.doNotDisplayMe}$index';

Expand All @@ -75,6 +77,7 @@ class SelectiveDisclosureDisplayMap {
isDeveloperMode: isDeveloperMode,
selectedClaimsKeyIds: selectedClaimsKeyIds,
onPressed: onPressed,
displayMode: displayMode,
).buildMap;
if (nestedMap.isNotEmpty) {
builtMap[title] = nestedMap;
Expand Down Expand Up @@ -200,6 +203,7 @@ class SelectiveDisclosureDisplayMap {
isDeveloperMode: isDeveloperMode,
selectedClaimsKeyIds: selectedClaimsKeyIds,
onPressed: onPressed,
displayMode: displayMode,
).buildMap;
if (mapNestedSelectiveDisclosure.isNotEmpty) {
builtMap.addAll({
Expand Down Expand Up @@ -238,6 +242,7 @@ class SelectiveDisclosureDisplayMap {
parentKeyId: element.key.toString(),
selectedClaimsKeyIds: selectedClaimsKeyIds,
onPressed: onPressed,
displayMode: displayMode,
).buildMap,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ class DisplaySelectiveDisclosure extends StatelessWidget {
selectedClaimsKeyIds:
selectiveDisclosureState?.selectedClaimsKeyIds ?? [],
onPressed: onPressed,
displayMode: context
.read<ProfileCubit>()
.state
.model
.profileSetting
.selfSovereignIdentityOptions
.customOidc4vcProfile
.displayMode,
).buildMap;

final List<Widget> listOfClaims =
Expand Down
20 changes: 10 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,10 @@ packages:
dependency: "direct main"
description:
name: dart_jsonwebtoken
sha256: "866787dc17afaef46a9ea7dd33eefe60c6d82084b4a36d70e8e788d091cd04ef"
sha256: "06e02e18827d047f206e1051c15b493c9c29a2dba0f9b2a905d73748dec4f931"
url: "https://pub.dev"
source: hosted
version: "2.14.2"
version: "2.16.0"
dart_style:
dependency: transitive
description:
Expand Down Expand Up @@ -565,10 +565,10 @@ packages:
dependency: transitive
description:
name: dbus
sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
sha256: "79e0c23480ff85dc68de79e2cd6334add97e48f7f4865d17686dd6ea81a47e8c"
url: "https://pub.dev"
source: hosted
version: "0.7.10"
version: "0.7.11"
decimal:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1151,10 +1151,10 @@ packages:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.3"
google_fonts:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1239,10 +1239,10 @@ packages:
dependency: "direct overridden"
description:
name: http
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
url: "https://pub.dev"
source: hosted
version: "1.2.2"
version: "1.3.0"
http_mock_adapter:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -1319,10 +1319,10 @@ packages:
dependency: transitive
description:
name: image_picker_macos
sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62"
sha256: "1b90ebbd9dcf98fb6c1d01427e49a55bd96b5d67b8c67cf955d60a5de74207c1"
url: "https://pub.dev"
source: hosted
version: "0.2.1+1"
version: "0.2.1+2"
image_picker_platform_interface:
dependency: transitive
description:
Expand Down

0 comments on commit b725ba4

Please sign in to comment.