Skip to content

Commit

Permalink
feat: Add new JWK Thumbprint P-256 key in the DID Manage Decebtralize…
Browse files Browse the repository at this point in the history
…d ID menu #2619
  • Loading branch information
bibash28 committed Apr 24, 2024
1 parent a9cee53 commit 4b06d40
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/dashboard/drawer/ssi/manage_did/manage_did.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export 'view/did/did_private_key_page.dart';
export 'view/did/manage_did_page.dart';
export 'view/did_polygon_id/manage_did_polygon_id_page.dart';
export 'view/jwk_thumbprint_p256_key/jwk_thumbprint_p256_key_page.dart';
export 'widgets/widgets.dart';
8 changes: 8 additions & 0 deletions lib/dashboard/drawer/ssi/manage_did/view/did_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ class DidView extends StatelessWidget {
}
},
),
DrawerItem(
title: l10n.jwkThumbprintP256Key,
onTap: () {
Navigator.of(context).push<void>(
JWKThumbprintP256KeyPage.route(),
);
},
),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class JWKThumbprintP256KeyPage extends StatefulWidget {
const JWKThumbprintP256KeyPage({
super.key,
});

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

@override
State<JWKThumbprintP256KeyPage> createState() =>
_JWKThumbprintP256KeyPageState();
}

class _JWKThumbprintP256KeyPageState extends State<JWKThumbprintP256KeyPage>
with SingleTickerProviderStateMixin {
late Animation<double> animation;
late AnimationController animationController;

Future<String> getKey() async {
final privateKey = await getP256KeyToGetAndPresentVC(
context.read<ProfileCubit>().secureStorageProvider,
);
return privateKey;
}

@override
void initState() {
super.initState();
animationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 20),
);

final Tween<double> rotationTween = Tween(begin: 20, end: 0);

animation = rotationTween.animate(animationController)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
Navigator.pop(context);
}
});
animationController.forward();
}

@override
void dispose() {
animationController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return BasePage(
scrollView: false,
title: l10n.jwkThumbprintP256Key,
titleAlignment: Alignment.topCenter,
titleLeading: const BackLeadingButton(),
secureScreen: true,
body: BackgroundCard(
width: double.infinity,
height: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
l10n.jwkThumbprintP256Key,
style: Theme.of(context).textTheme.title,
),
const SizedBox(
height: Sizes.spaceNormal,
),
FutureBuilder<String>(
future: getKey(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
return Column(
children: [
Text(
snapshot.data!,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: Sizes.spaceXLarge),
CopyButton(
onTap: () async {
await Clipboard.setData(
ClipboardData(text: snapshot.data!),
);
AlertMessage.showStateMessage(
context: context,
stateMessage: StateMessage.success(
stringMessage: l10n.copiedToClipboard,
),
);
},
),
],
);
case ConnectionState.waiting:
case ConnectionState.none:
case ConnectionState.active:
return const Text('');
}
},
),
Expanded(
child: Center(
child: AnimatedBuilder(
animation: animation,
builder: (BuildContext context, Widget? child) {
return Text(
timeFormatter(timeInSecond: animation.value.toInt()),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.displayMedium,
);
},
),
),
),
],
),
),
);
}
}
3 changes: 2 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1056,5 +1056,6 @@
"statusListIndex": "Status list index",
"theWalletIsSuspended": "The wallet is suspended.",
"clientTypeTitle": "Wallet Client_id Scheme",
"confidentialClient": "Confidential Client"
"confidentialClient": "Confidential Client",
"jwkThumbprintP256Key": "JWK Thumbprint P-256 Key"
}
9 changes: 6 additions & 3 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"statusListIndex",
"theWalletIsSuspended",
"clientTypeTitle",
"confidentialClient"
"confidentialClient",
"jwkThumbprintP256Key"
],

"es": [
Expand Down Expand Up @@ -54,7 +55,8 @@
"statusListIndex",
"theWalletIsSuspended",
"clientTypeTitle",
"confidentialClient"
"confidentialClient",
"jwkThumbprintP256Key"
],

"fr": [
Expand All @@ -73,6 +75,7 @@
"statusListIndex",
"theWalletIsSuspended",
"clientTypeTitle",
"confidentialClient"
"confidentialClient",
"jwkThumbprintP256Key"
]
}

0 comments on commit 4b06d40

Please sign in to comment.