show event color in popup

This commit is contained in:
Arnaud Vergnet 2021-05-11 09:08:05 +02:00
parent 115534f1c6
commit 46944a4487
2 changed files with 17 additions and 5 deletions

View file

@ -20,18 +20,24 @@
import * as React from 'react'; import * as React from 'react';
import { Button, Dialog, Paragraph, Portal } from 'react-native-paper'; import { Button, Dialog, Paragraph, Portal } from 'react-native-paper';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import { ViewStyle } from 'react-native';
type PropsType = { type PropsType = {
visible: boolean; visible: boolean;
onDismiss: () => void; onDismiss: () => void;
title: string | React.ReactNode; title: string | React.ReactNode;
message: string | React.ReactNode; message: string | React.ReactNode;
style?: ViewStyle;
}; };
function AlertDialog(props: PropsType) { function AlertDialog(props: PropsType) {
return ( return (
<Portal> <Portal>
<Dialog visible={props.visible} onDismiss={props.onDismiss}> <Dialog
visible={props.visible}
onDismiss={props.onDismiss}
style={props.style}
>
<Dialog.Title>{props.title}</Dialog.Title> <Dialog.Title>{props.title}</Dialog.Title>
<Dialog.Content> <Dialog.Content>
<Paragraph>{props.message}</Paragraph> <Paragraph>{props.message}</Paragraph>

View file

@ -160,6 +160,7 @@ function PlanexScreen(props: Props) {
| { | {
title: string | React.ReactElement; title: string | React.ReactElement;
message: string | React.ReactElement; message: string | React.ReactElement;
color: string;
} }
>(); >();
const [injectJS, setInjectJS] = useState(''); const [injectJS, setInjectJS] = useState('');
@ -269,7 +270,7 @@ function PlanexScreen(props: Props) {
if (startString != null && endString != null) { if (startString != null && endString != null) {
msg += `${startString} - ${endString}`; msg += `${startString} - ${endString}`;
} }
showDialog(data.title, msg); showDialog(data.title, msg, data.color);
}; };
/** /**
@ -278,7 +279,8 @@ function PlanexScreen(props: Props) {
* @param title The dialog's title * @param title The dialog's title
* @param message The message to show * @param message The message to show
*/ */
const showDialog = (title: string, message: string) => { const showDialog = (title: string, message: string, color?: string) => {
const finalColor = color ? color : theme.colors.surface;
setDialogContent({ setDialogContent({
title: ( title: (
<Autolink <Autolink
@ -292,6 +294,7 @@ function PlanexScreen(props: Props) {
/> />
), ),
message: message, message: message,
color: finalColor,
}); });
}; };
@ -329,8 +332,6 @@ function PlanexScreen(props: Props) {
* @param groupID The current group selected * @param groupID The current group selected
*/ */
const generateInjectedJS = (group: PlanexGroupType | undefined) => { const generateInjectedJS = (group: PlanexGroupType | undefined) => {
console.log(group);
let customInjectedJS = `$(document).ready(function() { let customInjectedJS = `$(document).ready(function() {
${OBSERVE_MUTATIONS_INJECTED} ${OBSERVE_MUTATIONS_INJECTED}
${INJECT_STYLE} ${INJECT_STYLE}
@ -386,6 +387,11 @@ function PlanexScreen(props: Props) {
onDismiss={hideDialog} onDismiss={hideDialog}
title={dialogContent ? dialogContent.title : ''} title={dialogContent ? dialogContent.title : ''}
message={dialogContent ? dialogContent.message : ''} message={dialogContent ? dialogContent.message : ''}
style={
dialogContent
? { borderColor: dialogContent.color, borderWidth: 2 }
: undefined
}
/> />
<AnimatedBottomBar <AnimatedBottomBar
navigation={navigation} navigation={navigation}