about summary refs log tree commit diff
path: root/src/view/com/util/layouts/TitleColumnLayout.tsx
blob: 3ca10868e0fe18a1e465cb14cf8262e924b28f76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react'
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
import {usePalette} from 'lib/hooks/usePalette'

interface Props {
  testID?: string
  title: React.Component
  horizontal: boolean
  titleStyle?: StyleProp<ViewStyle>
  contentStyle?: StyleProp<ViewStyle>
}

export function TitleColumnLayout({
  testID,
  title,
  horizontal,
  children,
  titleStyle,
  contentStyle,
}: React.PropsWithChildren<Props>) {
  const pal = usePalette('default')

  const layoutStyles = horizontal ? styles2Column : styles1Column
  return (
    <View testID={testID} style={layoutStyles.container}>
      <View style={[layoutStyles.title, pal.viewLight, titleStyle]}>
        {title}
      </View>
      <View style={[layoutStyles.content, contentStyle]}>{children}</View>
    </View>
  )
}

const styles2Column = StyleSheet.create({
  container: {
    flexDirection: 'row',
    height: '100%',
  },
  title: {
    flex: 1,
    paddingHorizontal: 40,
    paddingBottom: 80,
    justifyContent: 'center',
  },
  content: {
    flex: 2,
    paddingHorizontal: 40,
    justifyContent: 'center',
  },
})

const styles1Column = StyleSheet.create({
  container: {},
  title: {
    paddingHorizontal: 40,
    paddingVertical: 40,
  },
  content: {
    paddingHorizontal: 40,
    paddingVertical: 40,
  },
})