forked from Memmy-App/memmy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
141 additions
and
244 deletions.
There are no files selected for viewing
Empty file.
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,64 @@ | ||
import React, {useRef, useState} from "react"; | ||
import {openLink} from "../../helpers/LinkHelper"; | ||
import {ChevronRightIcon, HStack, Icon, Pressable, Spacer, Text} from "native-base"; | ||
import {truncateImageLink, truncateLink} from "../../helpers/TextHelper"; | ||
import ImageModal, {ImageDetail} from "@dreamwalk-os/react-native-image-modal"; | ||
import FastImage from "react-native-fast-image"; | ||
import ImageModalScreen from "../screens/image/ImageModalScreen"; | ||
import {Dimensions} from "react-native"; | ||
|
||
interface ImageButtonProps { | ||
src: string | ||
} | ||
|
||
const ImageButton = ({src}: ImageButtonProps) => { | ||
const [visible, setVisible] = useState(false); | ||
|
||
const onPress = () => { | ||
setVisible(true); | ||
console.log("sup"); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Pressable onPress={onPress}> | ||
<HStack | ||
backgroundColor={"screen.700"} | ||
borderRadius={5} | ||
padding={2} | ||
flexDirection={"row"} | ||
alignItems={"center"} | ||
space={2} | ||
my={4} | ||
mx={5} | ||
> | ||
<FastImage | ||
style={{ | ||
height: 50, | ||
width: 50, | ||
}} | ||
resizeMode={"contain"} | ||
source={{ | ||
uri: src | ||
}} | ||
/> | ||
<Spacer /> | ||
<Text> | ||
{truncateImageLink(src)} | ||
</Text> | ||
<Spacer /> | ||
<ChevronRightIcon /> | ||
</HStack> | ||
</Pressable> | ||
|
||
<ImageDetail source={{uri: src}} origin={{ | ||
x: Dimensions.get("window").width / 2, | ||
y: Dimensions.get("window").height / 2, | ||
width: 100, | ||
height: 100 | ||
}} resizeMode={"contain"} swipeToDismiss={true} onClose={() => setVisible(false)} isOpen={visible} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default ImageButton; |
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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import sanitizeHtml from "sanitize-html"; | ||
import showdown from "showdown"; | ||
export const findImages = (text: string) => { | ||
const pattern = /!\[(.*?)\]\((.*?)\)/g; | ||
|
||
export const parseMarkdown = (text: string): string => { | ||
//const parsed = marked.parse(text); | ||
//return sanitizeHtml(parsed); | ||
//return parsed; | ||
const converter = new showdown.Converter(); | ||
return sanitizeHtml(converter.makeHtml(text)); | ||
let match; | ||
let imageUrl = null; | ||
|
||
while ((match = pattern.exec(text)) !== null) { | ||
const altText = match[1]; | ||
imageUrl = match[2]; | ||
break; | ||
} | ||
|
||
return imageUrl; | ||
}; |
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
Oops, something went wrong.