-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add searching by TNS on wallet address inputs
- Loading branch information
Showing
3 changed files
with
77 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { FC } from "react"; | ||
import { StyleProp, View, ViewStyle } from "react-native"; | ||
|
||
import { useNameSearch } from "../../hooks/search/useNameSearch"; | ||
import { useSelectedNetworkId } from "../../hooks/useSelectedNetwork"; | ||
import { layout } from "../../utils/style/layout"; | ||
import { AvatarWithName } from "../user/AvatarWithName"; | ||
|
||
// Used as a wrapper on a TextInput or something like. It allows to search a name in TNS and returns the address. | ||
export const SearchNSInputContainer: FC<{ | ||
searchText: string; | ||
onPressName: (userId: string) => void; | ||
style?: StyleProp<ViewStyle>; | ||
}> = ({ searchText, onPressName, style, children }) => { | ||
const selectedNetworkId = useSelectedNetworkId(); | ||
const { names } = useNameSearch({ | ||
networkId: selectedNetworkId, | ||
input: searchText, | ||
limit: 12, | ||
}); | ||
const hasNames = !!names.length; | ||
|
||
return ( | ||
<> | ||
{children} | ||
{hasNames && ( | ||
<View | ||
style={[ | ||
{ | ||
flexDirection: "row", | ||
flexWrap: "wrap", | ||
marginTop: layout.padding_x1_5, | ||
}, | ||
style, | ||
]} | ||
> | ||
{names.map((n) => ( | ||
<AvatarWithName | ||
key={n} | ||
networkId={selectedNetworkId} | ||
name={n} | ||
onPress={(userId) => onPressName(userId)} | ||
style={{ marginRight: layout.padding_x1 }} | ||
/> | ||
))} | ||
</View> | ||
)} | ||
</> | ||
); | ||
}; |
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