summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/components/MultiButton.tsx
blob: efd21ee9ca9e54900f0e1646834f3490bc4e6cac (plain)
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
import * as React from 'react';
import { Component, Styles, Types, View } from 'reactxp';

const SIDE_BUTTON_WIDTH = 50;

const styles = {
  buttonRow: Styles.createViewStyle({
    flexDirection: 'row',
  }),
  mainButton: Styles.createViewStyle({
    flex: 1,
    borderTopRightRadius: 0,
    borderBottomRightRadius: 0,
  }),
  sideButton: Styles.createViewStyle({
    borderTopLeftRadius: 0,
    borderBottomLeftRadius: 0,
    width: SIDE_BUTTON_WIDTH,
    alignItems: 'center',
    marginLeft: 1,
  }),
};

interface IProps {
  mainButton: React.ComponentType<IMainButtonProps>;
  sideButton: React.ComponentType<ISideButtonProps>;
}

export interface IMainButtonProps {
  textOffset: number;
  style?: Types.StyleRuleSetRecursive<Types.ViewStyleRuleSet>;
}

export interface ISideButtonProps {
  style?: Types.StyleRuleSetRecursive<Types.ViewStyleRuleSet>;
}

export class MultiButton extends Component<IProps> {
  public render() {
    const { mainButton: MainButton, sideButton: SideButton } = this.props;

    return (
      <View style={styles.buttonRow}>
        <MainButton textOffset={SIDE_BUTTON_WIDTH} style={styles.mainButton} />
        <SideButton style={styles.sideButton} />
      </View>
    );
  }
}