-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Fetch verifier metadata from link #3009
- Loading branch information
Showing
9 changed files
with
134 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
lib/dashboard/drawer/ssi/verifiers_metadata/verifiers_metadata.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'view/verifiers_metadata_page.dart'; |
72 changes: 72 additions & 0 deletions
72
lib/dashboard/drawer/ssi/verifiers_metadata/view/verifiers_metadata_page.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<dynamic> route() => MaterialPageRoute<void>( | ||
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<String> getData() async { | ||
try { | ||
final response = await DioClient( | ||
secureStorageProvider: getSecureStorage, | ||
dio: Dio(), | ||
).get(Parameters.walletMetadataForVerifier); | ||
final data = response is String | ||
? jsonDecode(response) as Map<String, dynamic> | ||
: response as Map<String, dynamic>; | ||
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<String>( | ||
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()); | ||
} | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export 'view/json_viewer_page.dart'; | ||
export 'widget/json_viewer_widget.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>(.*?)<\/b>'); | ||
final matches = pattern.allMatches(data); | ||
|
||
final textSpans = <TextSpan>[]; | ||
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'json_viewer_widget.dart'; |