Skip to content

Commit

Permalink
fix: w3c fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
  • Loading branch information
sairanjit committed Jul 4, 2024
1 parent e90a730 commit 25bc49b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
20 changes: 6 additions & 14 deletions app/components/record/W3CCredentialRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ export interface RecordProps {
const W3CCredentialRecord: React.FC<RecordProps> = ({
header,
footer,
fields,
hideFieldValues = false,
tables,
w3cCredential,
renderCertificate,
}) => {
const { t } = useTranslation()
const [shown, setShown] = useState<boolean[]>([])
const [showAll, setShowAll] = useState<boolean>(false)
const [shown, setShown] = useState<boolean[][]>([])
const [showAll, setShowAll] = useState<boolean>(true)
const { ListItems, TextTheme, ColorPallet } = useTheme()

const styles = StyleSheet.create({
Expand Down Expand Up @@ -66,19 +65,13 @@ const W3CCredentialRecord: React.FC<RecordProps> = ({
})

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 (
<FlatList
Expand Down Expand Up @@ -110,11 +103,10 @@ const W3CCredentialRecord: React.FC<RecordProps> = ({
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}
/>
))}
Expand Down
2 changes: 1 addition & 1 deletion app/components/record/W3CCredentialRecordField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const W3CCredentialRecordField: React.FC<W3CCredentialRecordFieldProps> = ({
) : null}
</>
</View>
{<View style={[styles.border, hideBottomBorder && { borderBottomWidth: 0 }]} />}
<View style={[styles.border, hideBottomBorder && { borderBottomWidth: 0 }]} />
</View>
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/navigators/ContactStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const ContactStack: React.FC = () => {
<Stack.Screen
name={Screens.CredentialDetailsW3C}
component={CredentialDetailsW3C}
options={{ title: t('Screens.CredentialDetailsW3C') }}
options={{ title: t('Screens.CredentialDetails') }}
/>
<Stack.Screen
name={Screens.CredentialOffer}
Expand Down
2 changes: 1 addition & 1 deletion app/navigators/CredentialStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const CredentialStack: React.FC = () => {
<Stack.Screen
name={Screens.CredentialDetailsW3C}
component={CredentialDetailsW3C}
options={{ title: t('Screens.CredentialDetailsW3C') }}
options={{ title: t('Screens.CredentialDetails') }}
/>
<Stack.Screen
name={Screens.RenderCertificate}
Expand Down
3 changes: 2 additions & 1 deletion app/screens/ImportWalletConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SingleContextStorageLruCache,
CacheModule,
MediatorPickupStrategy,
WebDidResolver,
} from '@adeya/ssi'
import { PolygonDidResolver, PolygonModule } from '@ayanworks/credo-polygon-w3c-module'
import { StackScreenProps } from '@react-navigation/stack'
Expand Down Expand Up @@ -159,7 +160,7 @@ const ImportWalletVerify: React.FC<ImportWalletVerifyProps> = ({ 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({
Expand Down
3 changes: 2 additions & 1 deletion app/screens/Splash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 25bc49b

Please sign in to comment.