weechatRN

Weechat relay client for iOS using websockets https://github.com/mhoran/weechatRN
git clone http://git.hanabi.in/repos/weechatRN.git
Log | Files | Refs | README | LICENSE

commit 221539b0168a29a349bb0d23726873bcf2bced74
parent 6f466cb60b002b2638a3b14075a4096604b12bab
Author: Johan Lindskogen <johan.lindskogen@gmail.com>
Date:   Sun,  1 Apr 2018 18:13:48 +0200

Extract BufferListItem component

Diffstat:
Msrc/usecase/buffers/ui/BufferList.tsx | 54+-----------------------------------------------------
Asrc/usecase/buffers/ui/BufferListItem.tsx | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 53 deletions(-)

diff --git a/src/usecase/buffers/ui/BufferList.tsx b/src/usecase/buffers/ui/BufferList.tsx @@ -7,41 +7,7 @@ import { FlatList, View } from "react-native"; - -interface BufferListItemProps { - buffer: WeechatBuffer; - currentBufferId: string; - onSelectBuffer: (b: WeechatBuffer) => any; -} - -const BufferListItem = ({ - buffer, - currentBufferId, - onSelectBuffer -}: BufferListItemProps) => ( - <TouchableHighlight - onPress={() => onSelectBuffer(buffer)} - underlayColor="#F2777A" - style={[ - styles.listItem, - currentBufferId === buffer.id ? { backgroundColor: "#F2777A" } : null - ]} - > - <View style={styles.row}> - <View style={styles.bufferName}> - <Text - style={[ - styles.listItemText, - currentBufferId !== buffer.id ? { color: "#888" } : null - ]} - > - {buffer.short_name || buffer.full_name} - </Text> - </View> - <Text style={styles.listItemText}>1</Text> - </View> - </TouchableHighlight> -); +import { BufferListItem } from "./BufferListItem"; interface Props { buffers: WeechatBuffer[]; @@ -80,23 +46,5 @@ const styles = StyleSheet.create({ }, topbar: { height: 30 - }, - row: { - flexDirection: "row" - }, - bufferName: { - flex: 1 - }, - listItem: { - flex: 1, - height: 40, - paddingHorizontal: 20, - justifyContent: "center" - }, - listItemText: { - color: "#eee", - fontFamily: "Thonburi", - fontWeight: "bold", - fontSize: 15 } }); diff --git a/src/usecase/buffers/ui/BufferListItem.tsx b/src/usecase/buffers/ui/BufferListItem.tsx @@ -0,0 +1,65 @@ +import * as React from "react"; +import { + StyleSheet, + Dimensions, + Text, + TouchableHighlight, + FlatList, + View +} from "react-native"; + +interface Props { + buffer: WeechatBuffer; + currentBufferId: string; + onSelectBuffer: (b: WeechatBuffer) => any; +} + +export const BufferListItem = ({ + buffer, + currentBufferId, + onSelectBuffer +}: Props) => ( + <TouchableHighlight + onPress={() => onSelectBuffer(buffer)} + underlayColor="#F2777A" + style={[ + styles.listItem, + currentBufferId === buffer.id ? { backgroundColor: "#F2777A" } : null + ]} + > + <View style={styles.row}> + <View style={styles.bufferName}> + <Text + style={[ + styles.listItemText, + currentBufferId !== buffer.id ? { color: "#888" } : null + ]} + > + {buffer.short_name || buffer.full_name} + </Text> + </View> + <Text style={styles.listItemText}>1</Text> + </View> + </TouchableHighlight> +); + +const styles = StyleSheet.create({ + listItem: { + flex: 1, + height: 40, + paddingHorizontal: 20, + justifyContent: "center" + }, + listItemText: { + color: "#eee", + fontFamily: "Thonburi", + fontWeight: "bold", + fontSize: 15 + }, + row: { + flexDirection: "row" + }, + bufferName: { + flex: 1 + } +});