|
|
@@ -172,90 +172,85 @@ const CodeViewer = ({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- return (
|
|
|
- <View
|
|
|
- ref={containerRef}
|
|
|
+ return <View
|
|
|
+ ref={containerRef}
|
|
|
+ style={[
|
|
|
+ stylesheet.container,
|
|
|
+ containerDynamicStyle
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ <ScrollView
|
|
|
+ contentContainerStyle={stylesheet.scrollContent}
|
|
|
+ showsHorizontalScrollIndicator={true}
|
|
|
+ horizontal={true}
|
|
|
style={[
|
|
|
- stylesheet.container,
|
|
|
- containerDynamicStyle
|
|
|
+ stylesheet.scrollView,
|
|
|
+ {
|
|
|
+ paddingVertical: spaces.spacingSm
|
|
|
+ }
|
|
|
]}
|
|
|
>
|
|
|
- <ScrollView
|
|
|
- contentContainerStyle={stylesheet.scrollContent}
|
|
|
- showsHorizontalScrollIndicator={true}
|
|
|
- horizontal={true}
|
|
|
- style={{
|
|
|
- paddingVertical: spaces.spacingSm,
|
|
|
- flex: 1
|
|
|
- }}
|
|
|
+ <Text
|
|
|
+ style={[
|
|
|
+ stylesheet.content,
|
|
|
+ textDynamicStyle
|
|
|
+ ]}
|
|
|
>
|
|
|
- <Text
|
|
|
- style={[
|
|
|
- stylesheet.content,
|
|
|
- textDynamicStyle
|
|
|
- ]}
|
|
|
+ {language ? <Text
|
|
|
+ color="low"
|
|
|
>
|
|
|
- {language ? <Text
|
|
|
- color="low"
|
|
|
+ // {language}{"\n\n"}
|
|
|
+ </Text> : null}
|
|
|
+ {tokens.map((token, index) => {
|
|
|
+ return <NativeText
|
|
|
+ key={`code-token-${index}`}
|
|
|
+ style={{
|
|
|
+ fontFamily: Platform.OS === "web" ? "monospace" : "System",
|
|
|
+ color: getTokenColor(token.type)
|
|
|
+ }}
|
|
|
>
|
|
|
- // {language}{"\n\n"}
|
|
|
- </Text> : null}
|
|
|
- {tokens.map((token, index) => {
|
|
|
- return (
|
|
|
- <NativeText
|
|
|
- key={`code-token-${index}`}
|
|
|
- style={{
|
|
|
- fontFamily: Platform.OS === "web" ? "monospace" : "System",
|
|
|
- color: getTokenColor(token.type)
|
|
|
- }}
|
|
|
- >
|
|
|
- {token.value}
|
|
|
- </NativeText>
|
|
|
- );
|
|
|
- })}
|
|
|
- </Text>
|
|
|
- </ScrollView>
|
|
|
- <View
|
|
|
- style={{
|
|
|
+ {token.value}
|
|
|
+ </NativeText>;
|
|
|
+ })}
|
|
|
+ </Text>
|
|
|
+ </ScrollView>
|
|
|
+ <View
|
|
|
+ style={[
|
|
|
+ stylesheet.stickyActionContainer,
|
|
|
+ {
|
|
|
transform: [
|
|
|
{
|
|
|
translateY: stickyTop
|
|
|
}
|
|
|
],
|
|
|
- marginLeft: spaces.spacingMd,
|
|
|
- alignSelf: "flex-start",
|
|
|
- zIndex: 1
|
|
|
+ marginLeft: spaces.spacingMd
|
|
|
+ }
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ <Button
|
|
|
+ spreadBehaviour="free"
|
|
|
+ icon={({
|
|
|
+ color,
|
|
|
+ size
|
|
|
+ }) => {
|
|
|
+ if (isCopied) {
|
|
|
+ return <CheckIcon
|
|
|
+ color={colors.content.icon.success}
|
|
|
+ size={size + 5}
|
|
|
+ />;
|
|
|
+ }
|
|
|
+
|
|
|
+ return <CopyIcon
|
|
|
+ color={colors.content.icon[color]}
|
|
|
+ size={size + 5}
|
|
|
+ />;
|
|
|
}}
|
|
|
- >
|
|
|
- <Button
|
|
|
- spreadBehaviour="free"
|
|
|
- icon={({
|
|
|
- color,
|
|
|
- size
|
|
|
- }) => {
|
|
|
- if (isCopied) {
|
|
|
- return (
|
|
|
- <CheckIcon
|
|
|
- color={colors.content.icon.success}
|
|
|
- size={size + 5}
|
|
|
- />
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- return (
|
|
|
- <CopyIcon
|
|
|
- color={colors.content.icon[color]}
|
|
|
- size={size + 5}
|
|
|
- />
|
|
|
- );
|
|
|
- }}
|
|
|
- onPress={handleCopyCode}
|
|
|
- variant="ghost"
|
|
|
- type="neutral"
|
|
|
- size="small"
|
|
|
- />
|
|
|
- </View>
|
|
|
+ onPress={handleCopyCode}
|
|
|
+ variant="ghost"
|
|
|
+ type="neutral"
|
|
|
+ size="small"
|
|
|
+ />
|
|
|
</View>
|
|
|
- );
|
|
|
+ </View>;
|
|
|
};
|
|
|
export default CodeViewer;
|