From 25bc49bac58545415e50992b68a2e8b579623ebd Mon Sep 17 00:00:00 2001 From: Sai Ranjit Tummalapalli Date: Thu, 4 Jul 2024 17:48:34 +0530 Subject: [PATCH] fix: w3c fixes Signed-off-by: Sai Ranjit Tummalapalli --- app/components/record/W3CCredentialRecord.tsx | 20 ++++++------------- .../record/W3CCredentialRecordField.tsx | 2 +- app/navigators/ContactStack.tsx | 2 +- app/navigators/CredentialStack.tsx | 2 +- app/screens/ImportWalletConfirmation.tsx | 3 ++- app/screens/Splash.tsx | 3 ++- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/app/components/record/W3CCredentialRecord.tsx b/app/components/record/W3CCredentialRecord.tsx index 8f9a58e85..caef85f76 100644 --- a/app/components/record/W3CCredentialRecord.tsx +++ b/app/components/record/W3CCredentialRecord.tsx @@ -28,15 +28,14 @@ export interface RecordProps { const W3CCredentialRecord: React.FC = ({ header, footer, - fields, hideFieldValues = false, tables, w3cCredential, renderCertificate, }) => { const { t } = useTranslation() - const [shown, setShown] = useState([]) - const [showAll, setShowAll] = useState(false) + const [shown, setShown] = useState([]) + const [showAll, setShowAll] = useState(true) const { ListItems, TextTheme, ColorPallet } = useTheme() const styles = StyleSheet.create({ @@ -66,19 +65,13 @@ const W3CCredentialRecord: React.FC = ({ }) const resetShown = (): void => { - setShown(fields.map(() => showAll)) + setShown(tables.map(table => table.rows.map(() => showAll))) setShowAll(!showAll) } - const toggleShownState = (newShowStates: boolean[]): void => { - if (newShowStates.filter(shownState => shownState === showAll).length > Math.floor(fields.length / 2)) { - setShowAll(!showAll) - } - } - useEffect(() => { resetShown() - }, []) + }, [tables]) return ( = ({ hideFieldValue={hideFieldValues} onToggleViewPressed={() => { const newShowState = [...shown] - newShowState[index] = !shown[index] + newShowState[index][idx] = !shown[index][idx] setShown(newShowState) - toggleShownState(newShowState) }} - shown={hideFieldValues ? !!shown[index] : true} + shown={hideFieldValues ? !!(shown?.[index]?.[idx] ?? false) : true} hideBottomBorder={idx === table.rows.length - 1} /> ))} diff --git a/app/components/record/W3CCredentialRecordField.tsx b/app/components/record/W3CCredentialRecordField.tsx index c8e5c8cc5..069fc697f 100644 --- a/app/components/record/W3CCredentialRecordField.tsx +++ b/app/components/record/W3CCredentialRecordField.tsx @@ -98,7 +98,7 @@ const W3CCredentialRecordField: React.FC = ({ ) : null} - {} + ) } diff --git a/app/navigators/ContactStack.tsx b/app/navigators/ContactStack.tsx index 8c63d5d90..a813bc4f9 100644 --- a/app/navigators/ContactStack.tsx +++ b/app/navigators/ContactStack.tsx @@ -62,7 +62,7 @@ const ContactStack: React.FC = () => { { = ({ navigation }) = }), polygon: new PolygonModule({}), dids: new DidsModule({ - resolvers: [new PolygonDidResolver(), new IndyVdrIndyDidResolver()], + resolvers: [new PolygonDidResolver(), new IndyVdrIndyDidResolver(), new WebDidResolver()], }), cache: new CacheModule({ cache: new SingleContextStorageLruCache({ diff --git a/app/screens/Splash.tsx b/app/screens/Splash.tsx index cc9847b0a..da72c5f20 100644 --- a/app/screens/Splash.tsx +++ b/app/screens/Splash.tsx @@ -9,6 +9,7 @@ import { CacheModule, SingleContextStorageLruCache, MediatorPickupStrategy, + WebDidResolver, } from '@adeya/ssi' import { PolygonDidResolver, PolygonModule } from '@ayanworks/credo-polygon-w3c-module' import AsyncStorage from '@react-native-async-storage/async-storage' @@ -298,7 +299,7 @@ const Splash: React.FC = () => { }), polygon: new PolygonModule({}), dids: new DidsModule({ - resolvers: [new PolygonDidResolver(), new IndyVdrIndyDidResolver()], + resolvers: [new PolygonDidResolver(), new IndyVdrIndyDidResolver(), new WebDidResolver()], }), cache: new CacheModule({ cache: new SingleContextStorageLruCache({