Browse Source

show event color in popup

Arnaud Vergnet 6 months ago
parent
commit
46944a4487
2 changed files with 17 additions and 5 deletions
  1. 7
    1
      src/components/Dialogs/AlertDialog.tsx
  2. 10
    4
      src/screens/Planex/PlanexScreen.tsx

+ 7
- 1
src/components/Dialogs/AlertDialog.tsx View File

@@ -20,18 +20,24 @@
20 20
 import * as React from 'react';
21 21
 import { Button, Dialog, Paragraph, Portal } from 'react-native-paper';
22 22
 import i18n from 'i18n-js';
23
+import { ViewStyle } from 'react-native';
23 24
 
24 25
 type PropsType = {
25 26
   visible: boolean;
26 27
   onDismiss: () => void;
27 28
   title: string | React.ReactNode;
28 29
   message: string | React.ReactNode;
30
+  style?: ViewStyle;
29 31
 };
30 32
 
31 33
 function AlertDialog(props: PropsType) {
32 34
   return (
33 35
     <Portal>
34
-      <Dialog visible={props.visible} onDismiss={props.onDismiss}>
36
+      <Dialog
37
+        visible={props.visible}
38
+        onDismiss={props.onDismiss}
39
+        style={props.style}
40
+      >
35 41
         <Dialog.Title>{props.title}</Dialog.Title>
36 42
         <Dialog.Content>
37 43
           <Paragraph>{props.message}</Paragraph>

+ 10
- 4
src/screens/Planex/PlanexScreen.tsx View File

@@ -160,6 +160,7 @@ function PlanexScreen(props: Props) {
160 160
     | {
161 161
         title: string | React.ReactElement;
162 162
         message: string | React.ReactElement;
163
+        color: string;
163 164
       }
164 165
   >();
165 166
   const [injectJS, setInjectJS] = useState('');
@@ -269,7 +270,7 @@ function PlanexScreen(props: Props) {
269 270
     if (startString != null && endString != null) {
270 271
       msg += `${startString} - ${endString}`;
271 272
     }
272
-    showDialog(data.title, msg);
273
+    showDialog(data.title, msg, data.color);
273 274
   };
274 275
 
275 276
   /**
@@ -278,7 +279,8 @@ function PlanexScreen(props: Props) {
278 279
    * @param title The dialog's title
279 280
    * @param message The message to show
280 281
    */
281
-  const showDialog = (title: string, message: string) => {
282
+  const showDialog = (title: string, message: string, color?: string) => {
283
+    const finalColor = color ? color : theme.colors.surface;
282 284
     setDialogContent({
283 285
       title: (
284 286
         <Autolink
@@ -292,6 +294,7 @@ function PlanexScreen(props: Props) {
292 294
         />
293 295
       ),
294 296
       message: message,
297
+      color: finalColor,
295 298
     });
296 299
   };
297 300
 
@@ -329,8 +332,6 @@ function PlanexScreen(props: Props) {
329 332
    * @param groupID The current group selected
330 333
    */
331 334
   const generateInjectedJS = (group: PlanexGroupType | undefined) => {
332
-    console.log(group);
333
-
334 335
     let customInjectedJS = `$(document).ready(function() {
335 336
       ${OBSERVE_MUTATIONS_INJECTED}
336 337
       ${INJECT_STYLE}
@@ -386,6 +387,11 @@ function PlanexScreen(props: Props) {
386 387
         onDismiss={hideDialog}
387 388
         title={dialogContent ? dialogContent.title : ''}
388 389
         message={dialogContent ? dialogContent.message : ''}
390
+        style={
391
+          dialogContent
392
+            ? { borderColor: dialogContent.color, borderWidth: 2 }
393
+            : undefined
394
+        }
389 395
       />
390 396
       <AnimatedBottomBar
391 397
         navigation={navigation}

Loading…
Cancel
Save