Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions packages/components/src/ActionGroup/ActionGroupButtons.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import React from 'react';

import { View } from 'react-native';
import { Dimensions, View } from 'react-native';

import { Button, FAB, MD3LightTheme } from '@jmstechnologiesinc/react-native-paper';
import { Button, FAB, MD3LightTheme, } from '@jmstechnologiesinc/react-native-paper';
import { itemSeparator } from '../utils';

const isPrimaryButton = (buttonLength, index) => index === buttonLength - 1;

const isGreaterThan = (arr) => {
return arr.some(item => {
const numericValue = parseFloat(item.title.replace('Update ·', '').replace('$', '').trim().replace(',', ''));
return numericValue >= 1000;
});
}

const ActionGroupButtons = ({ buttons, isLoading, isStretched = false, style, onPress, variant = 'button' }) => {

const { width } = Dimensions.get('window');

if (!buttons.length) {
return null;
}

const isGreaterText = width <= 600 && isGreaterThan(buttons) ? 1.2 : 1

return (
<View style={[{ flexDirection: 'row', justifyContent: 'flex-end', flex: 1 }]}>
<View style={[{ flexDirection: 'row', justifyContent: 'flex-end', flex: isGreaterText }]}>
{buttons.map((button, index) => {
return (
<View
Expand All @@ -33,8 +45,8 @@ const ActionGroupButtons = ({ buttons, isLoading, isStretched = false, style, on
button.variant
? button.variant
: isPrimaryButton(buttons.length, index)
? 'primary'
: 'secondary'
? 'primary'
: 'secondary'
}
label={button.title}
onPress={() => onPress?.(button)}
Expand All @@ -51,11 +63,12 @@ const ActionGroupButtons = ({ buttons, isLoading, isStretched = false, style, on
button.mode
? button.mode
: isPrimaryButton(buttons.length, index)
? 'contained'
: 'outlined'
? 'contained'
: 'outlined'
}
icon={button.icon}
onPress={() => onPress?.(button)}

>
{button.title}
</Button>
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/Localization/Translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"appRequiresGeolocation": "This app needs your location to recommend nearby vendors around you, and provide positioning services, such as precise driver monitoring, real-time arrival estimate and delivery options.",
"addLocation": "Add Location",
"pleaseTryagain": "Please try again",
"anErrorOccurred": "An Error Occurred",
"requestProcessingError": "An error occured while procesing your request.",
"industries": "Industries",
"isLoading": "Loading...",
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/Localization/Translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"appRequiresGeolocation": "Esta aplicación necesita su ubicación para recomendar vendedores cercanos a su alrededor y brindar servicios de posicionamiento, como monitoreo preciso del conductor, estimación de llegada en tiempo real y opciones de entrega.",
"addLocation": "Agregar ubicación",
"pleaseTryagain": "Por favor, inténtalo de nuevo",
"anErrorOccurred": "Hubo un Error",
"requestProcessingError": "Se produjo un error al procesar tu solicitud.",
"industries": "Industrias",
"isLoading": "Cargando...",
Expand Down