diff --git a/lib/app/shared/constants/parameters.dart b/lib/app/shared/constants/parameters.dart index 33ce7da44..c6a2580a6 100644 --- a/lib/app/shared/constants/parameters.dart +++ b/lib/app/shared/constants/parameters.dart @@ -118,6 +118,11 @@ class Parameters { // 'https://app.altme.io/wallet_issuer' for altme static const String walletIssuer = 'https://app.altme.io/wallet_issuer'; + // 'https://app.talao.co/wallet-issuer/.well-known/openid-configuration'for talao + // 'https://app.altme.io/wallet-issuer/.well-known/openid-configuration' for altme + static const String walletMetadataForVerifier = + 'https://app.altme.io/wallet-issuer/.well-known/openid-configuration'; + static const DidKeyType didKeyTypeForEbsiV3 = DidKeyType.ebsiv3; static const DidKeyType didKeyTypeForEbsiV4 = DidKeyType.ebsiv4; static const DidKeyType didKeyTypeForDefault = DidKeyType.edDSA; diff --git a/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart b/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart index c712edd42..d3ab5f826 100644 --- a/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart +++ b/lib/dashboard/drawer/ssi/oidc4vc_settngs/view/oidc4vc_settings_menu.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:altme/app/app.dart'; import 'package:altme/dashboard/dashboard.dart'; +import 'package:altme/dashboard/drawer/ssi/verifiers_metadata/view/verifiers_metadata_page.dart'; import 'package:flutter/material.dart'; class Oidc4vcSettingMenu extends StatelessWidget { @@ -65,15 +66,7 @@ class Oidc4vcSettingMenuView extends StatelessWidget { DrawerItem( title: 'Wallet metadata for verifiers', onTap: () { - final value = const JsonEncoder.withIndent(' ').convert( - ConstantsJson.walletMetadataForVerifiers, - ); - Navigator.of(context).push( - JsonViewerPage.route( - title: 'Wallet metadata for verifiers', - data: value, - ), - ); + Navigator.of(context).push(VerifiersMetadataPage.route()); }, ), ], diff --git a/lib/dashboard/drawer/ssi/ssi.dart b/lib/dashboard/drawer/ssi/ssi.dart index d63269992..c774fa13f 100644 --- a/lib/dashboard/drawer/ssi/ssi.dart +++ b/lib/dashboard/drawer/ssi/ssi.dart @@ -2,3 +2,4 @@ export 'manage_did/manage_did.dart'; export 'oidc4vc_settngs/oidc4vc_settings.dart'; export 'src/src.dart'; export 'trust_framework/trust_framework.dart'; +export 'verifiers_metadata/verifiers_metadata.dart'; diff --git a/lib/dashboard/drawer/ssi/verifiers_metadata/verifiers_metadata.dart b/lib/dashboard/drawer/ssi/verifiers_metadata/verifiers_metadata.dart new file mode 100644 index 000000000..643c54be7 --- /dev/null +++ b/lib/dashboard/drawer/ssi/verifiers_metadata/verifiers_metadata.dart @@ -0,0 +1 @@ +export 'view/verifiers_metadata_page.dart'; diff --git a/lib/dashboard/drawer/ssi/verifiers_metadata/view/verifiers_metadata_page.dart b/lib/dashboard/drawer/ssi/verifiers_metadata/view/verifiers_metadata_page.dart new file mode 100644 index 000000000..181a512cb --- /dev/null +++ b/lib/dashboard/drawer/ssi/verifiers_metadata/view/verifiers_metadata_page.dart @@ -0,0 +1,72 @@ +import 'dart:convert'; + +import 'package:altme/app/app.dart'; +import 'package:altme/dashboard/dashboard.dart'; +import 'package:dio/dio.dart'; + +import 'package:flutter/material.dart'; +import 'package:secure_storage/secure_storage.dart'; + +class VerifiersMetadataPage extends StatelessWidget { + const VerifiersMetadataPage({super.key}); + + static Route route() => MaterialPageRoute( + builder: (_) => const VerifiersMetadataPage(), + settings: const RouteSettings(name: '/VerifiersMetadataPage'), + ); + + @override + Widget build(BuildContext context) { + return const VerifiersMetadataView(); + } +} + +class VerifiersMetadataView extends StatelessWidget { + const VerifiersMetadataView({super.key}); + + Future getData() async { + try { + final response = await DioClient( + secureStorageProvider: getSecureStorage, + dio: Dio(), + ).get(Parameters.walletMetadataForVerifier); + final data = response is String + ? jsonDecode(response) as Map + : response as Map; + final value = const JsonEncoder.withIndent(' ').convert(data); + return value; + } catch (e) { + return ''; + } + } + + @override + Widget build(BuildContext context) { + return BasePage( + title: 'Wallet metadata for verifiers', + titleAlignment: Alignment.topCenter, + titleLeading: const BackLeadingButton(), + padding: const EdgeInsets.only( + top: 0, + bottom: Sizes.spaceSmall, + left: Sizes.spaceSmall, + right: Sizes.spaceSmall, + ), + secureScreen: true, + body: FutureBuilder( + future: getData(), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.done: + return JsonViewWidget(data: snapshot.data.toString()); + + case ConnectionState.waiting: + case ConnectionState.none: + case ConnectionState.active: + return const Center(child: CircularProgressIndicator()); + } + }, + ), + ); + } +} diff --git a/lib/dashboard/json_viewer/json_viewer.dart b/lib/dashboard/json_viewer/json_viewer.dart index c590b3b38..5398c177b 100644 --- a/lib/dashboard/json_viewer/json_viewer.dart +++ b/lib/dashboard/json_viewer/json_viewer.dart @@ -1 +1,2 @@ export 'view/json_viewer_page.dart'; +export 'widget/json_viewer_widget.dart'; diff --git a/lib/dashboard/json_viewer/view/json_viewer_page.dart b/lib/dashboard/json_viewer/view/json_viewer_page.dart index 0592ce10d..99c5099c5 100644 --- a/lib/dashboard/json_viewer/view/json_viewer_page.dart +++ b/lib/dashboard/json_viewer/view/json_viewer_page.dart @@ -1,4 +1,5 @@ import 'package:altme/app/app.dart'; +import 'package:altme/dashboard/dashboard.dart'; import 'package:flutter/material.dart'; class JsonViewerPage extends StatelessWidget { @@ -44,52 +45,13 @@ class JsonViewerView extends StatelessWidget { @override Widget build(BuildContext context) { - final pattern = RegExp(r'(.*?)<\/b>'); - final matches = pattern.allMatches(data); - - final textSpans = []; - int currentIndex = 0; - - for (final match in matches) { - final plainText = data.substring(currentIndex, match.start); - final boldText = data.substring(match.start + 3, match.end - 4); - textSpans.add( - TextSpan( - text: plainText, - style: Theme.of(context).textTheme.bodyMedium, - ), - ); - textSpans.add( - TextSpan( - text: boldText, - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith(fontWeight: FontWeight.w700), - ), - ); - currentIndex = match.end; - } - - if (currentIndex < data.length) { - final remainingText = data.substring(currentIndex); - textSpans.add( - TextSpan( - text: remainingText, - style: Theme.of(context).textTheme.bodyMedium, - ), - ); - } - return BasePage( title: title, titleAlignment: Alignment.topCenter, scrollView: true, titleLeading: const BackLeadingButton(), padding: const EdgeInsets.symmetric(horizontal: 10), - body: RichText( - text: TextSpan(children: textSpans), - ), + body: JsonViewWidget(data: data), ); } } diff --git a/lib/dashboard/json_viewer/widget/json_viewer_widget.dart b/lib/dashboard/json_viewer/widget/json_viewer_widget.dart new file mode 100644 index 000000000..6b2325dc3 --- /dev/null +++ b/lib/dashboard/json_viewer/widget/json_viewer_widget.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; + +class JsonViewWidget extends StatelessWidget { + const JsonViewWidget({super.key, required this.data}); + + final String data; + + @override + Widget build(BuildContext context) { + final pattern = RegExp(r'(.*?)<\/b>'); + final matches = pattern.allMatches(data); + + final textSpans = []; + int currentIndex = 0; + + for (final match in matches) { + final plainText = data.substring(currentIndex, match.start); + final boldText = data.substring(match.start + 3, match.end - 4); + textSpans.add( + TextSpan( + text: plainText, + style: Theme.of(context).textTheme.bodyMedium, + ), + ); + textSpans.add( + TextSpan( + text: boldText, + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith(fontWeight: FontWeight.w700), + ), + ); + currentIndex = match.end; + } + + if (currentIndex < data.length) { + final remainingText = data.substring(currentIndex); + textSpans.add( + TextSpan( + text: remainingText, + style: Theme.of(context).textTheme.bodyMedium, + ), + ); + } + + return RichText(text: TextSpan(children: textSpans)); + } +} diff --git a/lib/dashboard/json_viewer/widget/widget.dart b/lib/dashboard/json_viewer/widget/widget.dart new file mode 100644 index 000000000..d97a8e946 --- /dev/null +++ b/lib/dashboard/json_viewer/widget/widget.dart @@ -0,0 +1 @@ +export 'json_viewer_widget.dart';