diff --git a/app/actions/apps.ts b/app/actions/apps.ts index ff2a86037..2c657a01c 100644 --- a/app/actions/apps.ts +++ b/app/actions/apps.ts @@ -88,24 +88,17 @@ export function doAppCall(call: AppCallRequest, type: AppCallType, const showAppForm = async (form: AppForm, call: AppCallRequest, theme: Theme) => { const closeButton = await CompassIcon.getImageSource('close', 24, theme.sidebarHeaderTextColor); - let submitButtons = [{ - id: 'submit-form', - showAsAction: 'always', - text: 'Submit', - }]; - if (form.submit_buttons) { - const options = form.fields.find((f) => f.name === form.submit_buttons)?.options; - const newButtons = options?.map((o) => { - return { - id: 'submit-form_' + o.value, - showAsAction: 'always', - text: o.label, - }; - }); - if (newButtons && newButtons.length > 0) { - submitButtons = newButtons; - } + let submitButtons; + const customSubmitButtons = form.submit_buttons && form.fields.find((f) => f.name === form.submit_buttons)?.options; + + if (!customSubmitButtons?.length) { + submitButtons = [{ + id: 'submit-form', + showAsAction: 'always', + text: 'Submit', + }]; } + const options = { topBar: { leftButtons: [{ diff --git a/app/screens/apps_form/apps_form_component.tsx b/app/screens/apps_form/apps_form_component.tsx index 2dfdbd203..27c8496db 100644 --- a/app/screens/apps_form/apps_form_component.tsx +++ b/app/screens/apps_form/apps_form_component.tsx @@ -3,9 +3,10 @@ import {intlShape} from 'react-intl'; import React, {PureComponent} from 'react'; -import {ScrollView, View} from 'react-native'; +import {ScrollView, Text, View} from 'react-native'; import {EventSubscription, Navigation} from 'react-native-navigation'; import {SafeAreaView} from 'react-native-safe-area-context'; +import Button from 'react-native-button'; import {AppCallResponseTypes} from '@mm-redux/constants/apps'; import {AppCallRequest, AppField, AppForm, AppFormValue, AppFormValues, AppLookupResponse, AppSelectOption, FormResponseData} from '@mm-redux/types/apps'; @@ -22,6 +23,7 @@ import {getMarkdownBlockStyles, getMarkdownTextStyles} from '@utils/markdown'; import {preventDoubleTap} from '@utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {DoAppCallResult} from 'types/actions/apps'; +import {GlobalStyles} from 'app/styles'; import AppsFormField from './apps_form_field'; import DialogIntroductionText from './dialog_introduction_text'; @@ -107,11 +109,6 @@ export default class AppsFormComponent extends PureComponent { return; case 'close-dialog': this.handleHide(); - return; - } - - if (buttonId.startsWith('submit-form_')) { - this.handleSubmit(buttonId.substr('submit-form_'.length)); } } @@ -333,6 +330,8 @@ export default class AppsFormComponent extends PureComponent { const {formError, fieldErrors, values} = this.state; const style = getStyleFromTheme(theme); + const submitButtons = fields && fields.find((f) => f.name === form.submit_buttons); + return ( { /> ); })} + + {submitButtons?.options?.map((o) => ( + + ))} + ); @@ -403,6 +415,12 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => { marginBottom: 20, marginTop: 10, }, + button: { + alignSelf: 'stretch', + backgroundColor: theme.sidebarHeaderBg, + borderRadius: 3, + padding: 15, + }, errorLabel: { fontSize: 12, textAlign: 'left',