Skip to content

Commit

Permalink
feat: Added profile page for oidc4vc profiles #1744
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jul 28, 2023
1 parent 7d8baec commit 7b7dc05
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/app/shared/constants/secure_storage_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ class SecureStorageKeys {
static const String buildNumber = 'buildNumber';

static const String hasVerifiedMnemonics = 'hasVerifiedMnemonics';

static const String oidc4vcType = 'oidc4vcType';
}
File renamed without changes.
3 changes: 2 additions & 1 deletion lib/app/shared/widget/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export 'dialog/dialog.dart';
export 'dialog_close_button.dart';
export 'display_terms.dart';
export 'error_view.dart';
export 'grouped_section.dart';
export 'hero_workaround.dart';
export 'image_card_text.dart';
export 'imported_tag.dart';
export 'imported_tag.dart';
export 'm_webview/m_webview.dart';
export 'mnemonic.dart';
export 'my_rich_text.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export 'grouped_section.dart';
export 'issuer_verifier_selector.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'view/oidc4vc_profile_page.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/profile/profile.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

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

static Route<dynamic> route() {
return MaterialPageRoute<void>(
builder: (_) => const OIDC4VCProfilePage(),
settings: const RouteSettings(name: '/OIDC4VCProfilePage'),
);
}

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return BasePage(
title: l10n.oidc4vcProfile,
useSafeArea: true,
scrollView: false,
titleAlignment: Alignment.topCenter,
padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceSmall),
titleLeading: const BackLeadingButton(),
body: BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
padding: const EdgeInsets.all(Sizes.spaceSmall),
margin: const EdgeInsets.all(Sizes.spaceXSmall),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.cardHighlighted,
borderRadius: const BorderRadius.all(
Radius.circular(Sizes.largeRadius),
),
),
child: ListView.builder(
itemCount: OIDC4VCTye.values.length,
shrinkWrap: true,
physics: const ScrollPhysics(),
itemBuilder: (context, index) {
return Column(
children: [
ListTile(
onTap: () {
context
.read<ProfileCubit>()
.updateOIDC4VCType(OIDC4VCTye.values[index]);
},
shape: const RoundedRectangleBorder(
side: BorderSide(
color: Color(0xFFDDDDEE), width: 0.5),
),
title: Text(
OIDC4VCTye.values[index].name,
style: Theme.of(context)
.listTileTheme
.titleTextStyle
?.copyWith(color: const Color(0xFF080F33)),
),
trailing: Icon(
state.model.oidc4vcType ==
OIDC4VCTye.values[index].toString()
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
size: Sizes.icon2x,
),
),
if (index < OIDC4VCTye.values.length - 1)
Padding(
padding: const EdgeInsets.symmetric(
horizontal: Sizes.spaceSmall,
vertical: Sizes.spaceXSmall,
),
child: Divider(
height: 0,
color: Theme.of(context).colorScheme.borderColor,
),
),
],
);
},
),
),
],
);
},
),
);
}
}
8 changes: 8 additions & 0 deletions lib/dashboard/drawer/ssi/src/view/ssi_menu.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/dashboard/drawer/ssi/manage_did/view/did_menu.dart';
import 'package:altme/dashboard/drawer/ssi/oidc4vc_profile/oidc4vc_profile.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -64,6 +65,13 @@ class SSIView extends StatelessWidget {
await Navigator.of(context).push<void>(RestoreMenu.route());
},
),
DrawerItem(
title: l10n.oidc4vcProfile,
onTap: () async {
await Navigator.of(context)
.push<void>(OIDC4VCProfilePage.route());
},
),
DrawerItem(
title: l10n.verifiableDataRegistry,
onTap: () async {
Expand Down
18 changes: 18 additions & 0 deletions lib/dashboard/profile/cubit/profile_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class ProfileCubit extends Cubit<ProfileState> {
(await secureStorageProvider.get(SecureStorageKeys.alertEnabled)) ==
'true';

final oidc4vcType =
(await secureStorageProvider.get(SecureStorageKeys.oidc4vcType)) ??
OIDC4VCTye.EBSIV2.toString();

final profileModel = ProfileModel(
firstName: firstName,
lastName: lastName,
Expand All @@ -108,6 +112,7 @@ class ProfileCubit extends Cubit<ProfileState> {
isEnterprise: isEnterprise,
isBiometricEnabled: isBiometricEnabled,
isAlertEnabled: isAlertEnabled,
oidc4vcType: oidc4vcType,
);

emit(
Expand Down Expand Up @@ -185,6 +190,11 @@ class ProfileCubit extends Cubit<ProfileState> {
profileModel.isAlertEnabled.toString(),
);

await secureStorageProvider.set(
SecureStorageKeys.oidc4vcType,
profileModel.oidc4vcType,
);

emit(
state.copyWith(
model: profileModel,
Expand Down Expand Up @@ -227,6 +237,14 @@ class ProfileCubit extends Cubit<ProfileState> {
await update(profileModel);
}

Future<void> updateOIDC4VCType(OIDC4VCTye oidc4vcTye) async {
emit(state.copyWith(status: AppStatus.loading));
final profileModel =
state.model.copyWith(oidc4vcType: oidc4vcTye.toString());

await update(profileModel);
}

@override
Future<void> close() async {
_timer?.cancel();
Expand Down
8 changes: 7 additions & 1 deletion lib/dashboard/profile/models/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ProfileModel extends Equatable {
this.companyName = '',
this.companyWebsite = '',
this.jobTitle = '',
required this.oidc4vcType,
});

factory ProfileModel.fromJson(Map<String, dynamic> json) =>
Expand All @@ -39,6 +40,7 @@ class ProfileModel extends Equatable {
isBiometricEnabled: false,
isAlertEnabled: false,
tezosNetwork: TezosNetwork.mainNet(),
oidc4vcType: OIDC4VCTye.EBSIV2.toString(),
);

final String firstName;
Expand All @@ -54,6 +56,7 @@ class ProfileModel extends Equatable {
final bool isEnterprise;
final bool isBiometricEnabled;
final bool isAlertEnabled;
final String oidc4vcType;

@override
List<Object> get props => [
Expand All @@ -69,7 +72,8 @@ class ProfileModel extends Equatable {
jobTitle,
isEnterprise,
isBiometricEnabled,
isAlertEnabled
isAlertEnabled,
oidc4vcType,
];

Map<String, dynamic> toJson() => _$ProfileModelToJson(this);
Expand All @@ -88,6 +92,7 @@ class ProfileModel extends Equatable {
bool? isEnterprise,
bool? isBiometricEnabled,
bool? isAlertEnabled,
String? oidc4vcType,
}) {
return ProfileModel(
firstName: firstName ?? this.firstName,
Expand All @@ -103,6 +108,7 @@ class ProfileModel extends Equatable {
isEnterprise: isEnterprise ?? this.isEnterprise,
isBiometricEnabled: isBiometricEnabled ?? this.isBiometricEnabled,
isAlertEnabled: isAlertEnabled ?? this.isAlertEnabled,
oidc4vcType: oidc4vcType ?? this.oidc4vcType,
);
}
}
3 changes: 2 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -924,5 +924,6 @@
"placeholders": {
"networkType": {}
}
}
},
"oidc4vcProfile": "OIDC4VC Profile"
}
12 changes: 8 additions & 4 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,8 @@
"burn",
"wouldYouLikeToConfirmThatYouIntendToBurnThisNFT",
"pleaseAddXtoConnectToTheDapp",
"pleaseSwitchPolygonNetwork"
"pleaseSwitchPolygonNetwork",
"oidc4vcProfile"
],

"es": [
Expand Down Expand Up @@ -1676,7 +1677,8 @@
"burn",
"wouldYouLikeToConfirmThatYouIntendToBurnThisNFT",
"pleaseAddXtoConnectToTheDapp",
"pleaseSwitchPolygonNetwork"
"pleaseSwitchPolygonNetwork",
"oidc4vcProfile"
],

"fr": [
Expand Down Expand Up @@ -1819,7 +1821,8 @@
"burn",
"wouldYouLikeToConfirmThatYouIntendToBurnThisNFT",
"pleaseAddXtoConnectToTheDapp",
"pleaseSwitchPolygonNetwork"
"pleaseSwitchPolygonNetwork",
"oidc4vcProfile"
],

"it": [
Expand Down Expand Up @@ -2659,6 +2662,7 @@
"burn",
"wouldYouLikeToConfirmThatYouIntendToBurnThisNFT",
"pleaseAddXtoConnectToTheDapp",
"pleaseSwitchPolygonNetwork"
"pleaseSwitchPolygonNetwork",
"oidc4vcProfile"
]
}

0 comments on commit 7b7dc05

Please sign in to comment.