Merge pull request #52 from djwesty/djwesty/51
Improve layout of decrement+increment buttons (Issue #51)
This commit is contained in:
commit
5265730c0c
@ -138,6 +138,7 @@ const IndexScreen: React.FC = () => {
|
|||||||
title={i18n.t("select_number_of_players")}
|
title={i18n.t("select_number_of_players")}
|
||||||
iconName={"people"}
|
iconName={"people"}
|
||||||
orientation="row"
|
orientation="row"
|
||||||
|
contentStyle={{ justifyContent: "center", gap: 30 }}
|
||||||
>
|
>
|
||||||
<PlayerSelector
|
<PlayerSelector
|
||||||
playerCount={playerCount}
|
playerCount={playerCount}
|
||||||
@ -170,6 +171,8 @@ const IndexScreen: React.FC = () => {
|
|||||||
<Section
|
<Section
|
||||||
title={i18n.t("manual_chip_adjustment")}
|
title={i18n.t("manual_chip_adjustment")}
|
||||||
iconName={"account-balance"}
|
iconName={"account-balance"}
|
||||||
|
orientation="row"
|
||||||
|
contentStyle={{ alignItems: "center" }}
|
||||||
>
|
>
|
||||||
<ChipsSelector
|
<ChipsSelector
|
||||||
totalChipsCount={totalChipsCount}
|
totalChipsCount={totalChipsCount}
|
||||||
|
@ -163,6 +163,13 @@ const ChipsSelector = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Button
|
||||||
|
title="-"
|
||||||
|
onPress={() => {
|
||||||
|
setNumberOfChips(Math.max(1, numberOfChips - 1));
|
||||||
|
}}
|
||||||
|
disabled={numberOfChips == 1}
|
||||||
|
/>
|
||||||
<View style={[styles.container, { flexDirection: "row" }]}>
|
<View style={[styles.container, { flexDirection: "row" }]}>
|
||||||
{colorsUsed.map((color) => (
|
{colorsUsed.map((color) => (
|
||||||
<Chip
|
<Chip
|
||||||
@ -173,22 +180,13 @@ const ChipsSelector = ({
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
<View style={[styles.container, { flexDirection: "row" }]}>
|
<Button
|
||||||
<Button
|
title="+"
|
||||||
title="-"
|
onPress={() => {
|
||||||
onPress={() => {
|
setNumberOfChips(Math.min(5, numberOfChips + 1));
|
||||||
setNumberOfChips(Math.max(1, numberOfChips - 1));
|
}}
|
||||||
}}
|
disabled={numberOfChips == 5}
|
||||||
disabled={numberOfChips == 1}
|
/>
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
title="+"
|
|
||||||
onPress={() => {
|
|
||||||
setNumberOfChips(Math.min(5, numberOfChips + 1));
|
|
||||||
}}
|
|
||||||
disabled={numberOfChips == 5}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<ChipInputModal
|
<ChipInputModal
|
||||||
showModal={showModal}
|
showModal={showModal}
|
||||||
|
@ -23,19 +23,17 @@ const PlayerSelector: React.FC<PlayerSelectorProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Button
|
||||||
|
title="-"
|
||||||
|
onPress={decreasePlayers}
|
||||||
|
disabled={playerCount <= MIN}
|
||||||
|
/>
|
||||||
<Text style={styles.h1}>{playerCount}</Text>
|
<Text style={styles.h1}>{playerCount}</Text>
|
||||||
<View style={{ flexDirection: "row", gap: 10 }}>
|
<Button
|
||||||
<Button
|
title="+"
|
||||||
title="-"
|
onPress={increasePlayers}
|
||||||
onPress={decreasePlayers}
|
disabled={playerCount >= MAX}
|
||||||
disabled={playerCount <= MIN}
|
/>
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
title="+"
|
|
||||||
onPress={increasePlayers}
|
|
||||||
disabled={playerCount >= MAX}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,19 @@ const titleCase = (input: string) =>
|
|||||||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
//Higher Order Component (HOC) for styling purposes
|
// Wrapper container for styling purposes
|
||||||
const Section = ({
|
const Section = ({
|
||||||
title,
|
title,
|
||||||
iconName,
|
iconName,
|
||||||
children,
|
children,
|
||||||
orientation = "column",
|
orientation = "column",
|
||||||
|
contentStyle = {},
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
iconName: string | any;
|
iconName: string | any;
|
||||||
children: React.JSX.Element;
|
children: React.JSX.Element;
|
||||||
orientation?: "row" | "column";
|
orientation?: "row" | "column";
|
||||||
|
contentStyle?: object;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
@ -32,7 +34,13 @@ const Section = ({
|
|||||||
/>
|
/>
|
||||||
<Text style={styles.title}>{titleCase(title)}</Text>
|
<Text style={styles.title}>{titleCase(title)}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ ...styles.content, flexDirection: orientation }}>
|
<View
|
||||||
|
style={{
|
||||||
|
...styles.content,
|
||||||
|
...contentStyle,
|
||||||
|
flexDirection: orientation,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
Loading…
Reference in New Issue
Block a user