-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from iuricmp/feat/mentions
feat: Add mentions on text renderer
- Loading branch information
Showing
9 changed files
with
146 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { colors } from "@gno/styles/colors"; | ||
import React from "react"; | ||
import Autolink, { CustomMatcher } from "react-native-autolink"; | ||
|
||
const PATTERN = /@([a-z]+[_a-z0-9]{5,})/g; | ||
|
||
type Props = { | ||
onMentionPress?: (accountName: string) => void; | ||
children: string; | ||
}; | ||
|
||
const PostContentLabel: React.FC<Props> = ({ children, onMentionPress }) => { | ||
return ( | ||
<Autolink | ||
text={children} | ||
email={false} | ||
url={false} | ||
matchers={[ | ||
{ | ||
pattern: PATTERN, | ||
style: { color: colors.blue, fontWeight: "bold" }, | ||
getLinkText: (replacerArgs) => `@${replacerArgs[1]}`, | ||
onPress: (match) => { | ||
console.log("Pressed mention1 ", match); | ||
|
||
const accountNameM1 = match.getReplacerArgs()[0]; | ||
const accountName = accountNameM1.replace("@", ""); | ||
|
||
onMentionPress ? onMentionPress(accountName) : null; | ||
}, | ||
}, | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
export default PostContentLabel; |
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
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,28 @@ | ||
import Layout from "@gno/components/layout"; | ||
import Text from "@gno/components/text"; | ||
import React from "react"; | ||
import styled from "styled-components/native"; | ||
|
||
type Props = { | ||
message?: string; | ||
}; | ||
|
||
export const ErrorView: React.FC<Props> = ({ message = "Loading" }) => { | ||
return ( | ||
<Layout.Container> | ||
<Layout.Body> | ||
<ViewCenter> | ||
<Text.BodyMedium>{message}</Text.BodyMedium> | ||
</ViewCenter> | ||
</Layout.Body> | ||
</Layout.Container> | ||
); | ||
}; | ||
|
||
const ViewCenter = styled.View` | ||
height: 100%; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
export default ErrorView; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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