git ssb

1+

Daan Patchwork / manyverse



Tree: 062a79b6023149b8244a20d0a5b597ccf3f0dce8

Files: 062a79b6023149b8244a20d0a5b597ccf3f0dce8 / src / frontend / components / dialogs / MarkdownDialog.ts

2564 bytesRaw
1/* Copyright (C) 2018-2020 The Manyverse Authors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7import {PureComponent, createElement as $} from 'react';
8import {View, Text, StyleSheet, Platform} from 'react-native';
9import {Options} from 'react-native-navigation';
10import {Dimensions} from '../../global-styles/dimens';
11import {Palette} from '../../global-styles/palette';
12import {Typography} from '../../global-styles/typography';
13import {t} from '../../drivers/localization';
14import Markdown from '../Markdown';
15import Dialog from './Dialog';
16import DialogButton from './DialogButton';
17
18export const styles = StyleSheet.create({
19 content: {
20 ...Platform.select({
21 default: {
22 paddingVertical: Dimensions.verticalSpaceLarger,
23 paddingHorizontal: Dimensions.horizontalSpaceLarge,
24 marginBottom: Dimensions.verticalSpaceLarge * 2,
25 },
26 ios: {
27 paddingVertical: Dimensions.verticalSpaceBig,
28 paddingHorizontal: Dimensions.horizontalSpaceBig,
29 },
30 }),
31 ...Platform.select({android: {minWidth: 300}}),
32 color: Palette.textWeak,
33 },
34
35 title: {
36 marginBottom: Dimensions.verticalSpaceNormal,
37 ...Platform.select({
38 default: {
39 fontFamily: 'normal',
40 textAlign: 'left',
41 },
42 ios: {
43 fontFamily: Typography.fontFamilyReadableText,
44 textAlign: 'center',
45 },
46 }),
47 fontSize: Typography.fontSizeBig,
48 fontWeight: 'bold',
49 color: Palette.text,
50 },
51
52 spacer: {
53 fontSize: Platform.select({ios: 5, default: Typography.fontSizeNormal}),
54 },
55});
56
57export type Props = {
58 title?: string;
59 content: string;
60 onClose?: () => {};
61};
62
63export default class TextDialog extends PureComponent<Props> {
64 public static navOptions: Options = Dialog.navOptions;
65
66 private onOkay = () => {
67 this.props.onClose?.();
68 };
69
70 public render() {
71 const {title, content} = this.props;
72 return $(Dialog, {key: 'dialog'}, [
73 $(View, {key: 'content', style: styles.content}, [
74 title ? $(Text, {key: 'title', style: styles.title}, title) : null,
75 $(Markdown, {key: 'md', text: content}),
76 ]),
77 $(DialogButton, {
78 key: 'button',
79 onPress: this.onOkay,
80 text: t('call_to_action.ok'),
81 accessible: true,
82 accessibilityLabel: t(
83 'call_to_action.close_dialog.accessibility_label',
84 ),
85 }),
86 ]);
87 }
88}
89

Built with git-ssb-web