about summary refs log tree commit diff
path: root/src/components/Dialog/shared.tsx
blob: eec47b2ba4d6778c40d8df66f77fa001f85fc0c3 (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
63
64
65
66
67
68
import React from 'react'
import {
  LayoutChangeEvent,
  StyleProp,
  TextStyle,
  View,
  ViewStyle,
} from 'react-native'

import {atoms as a, useTheme} from '#/alf'
import {Text} from '#/components/Typography'

export function Header({
  renderLeft,
  renderRight,
  children,
  style,
  onLayout,
}: {
  renderLeft?: () => React.ReactNode
  renderRight?: () => React.ReactNode
  children?: React.ReactNode
  style?: StyleProp<ViewStyle>
  onLayout?: (event: LayoutChangeEvent) => void
}) {
  const t = useTheme()
  return (
    <View
      onLayout={onLayout}
      style={[
        a.relative,
        a.w_full,
        a.py_sm,
        a.flex_row,
        a.justify_center,
        a.align_center,
        {minHeight: 50},
        a.border_b,
        t.atoms.border_contrast_medium,
        t.atoms.bg,
        {borderTopLeftRadius: a.rounded_md.borderRadius},
        {borderTopRightRadius: a.rounded_md.borderRadius},
        style,
      ]}>
      {renderLeft && (
        <View style={[a.absolute, {left: 6}]}>{renderLeft()}</View>
      )}
      {children}
      {renderRight && (
        <View style={[a.absolute, {right: 6}]}>{renderRight()}</View>
      )}
    </View>
  )
}

export function HeaderText({
  children,
  style,
}: {
  children?: React.ReactNode
  style?: StyleProp<TextStyle>
}) {
  return (
    <Text style={[a.text_lg, a.text_center, a.font_bold, style]}>
      {children}
    </Text>
  )
}