feat(mobile): display stone count in pit
This commit is contained in:
parent
ca92b20b59
commit
9c95d9dc44
@ -39,7 +39,10 @@ const BoardView: FunctionComponent<{
|
|||||||
key={key}
|
key={key}
|
||||||
pitViewModel={pitViewModel}
|
pitViewModel={pitViewModel}
|
||||||
onClick={() => onPitSelect(pit.index, pit)}
|
onClick={() => onPitSelect(pit.index, pit)}
|
||||||
style={{width: pitWidth, height: pitWidth}} >
|
style={{width: pitWidth, height: pitWidth}}
|
||||||
|
context={context}
|
||||||
|
fontSize={pitWidth / 5}
|
||||||
|
>
|
||||||
{stones}
|
{stones}
|
||||||
</PitView>;
|
</PitView>;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,19 +1,28 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { FunctionComponent } from "react";
|
import { FunctionComponent } from "react";
|
||||||
import { PitViewModel } from "@mancala/core";
|
import { PitViewModel, getColorByBrightness } from "@mancala/core";
|
||||||
import { Pressable, View, ViewStyle } from "react-native";
|
import { Context } from "../../context/context";
|
||||||
|
import { Pressable, View, ViewStyle, Text } from "react-native";
|
||||||
|
|
||||||
const PitView: FunctionComponent<{
|
const PitView: FunctionComponent<{
|
||||||
pitViewModel: PitViewModel;
|
pitViewModel: PitViewModel;
|
||||||
|
context: Context;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
style: ViewStyle,
|
style: ViewStyle,
|
||||||
|
fontSize: number;
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}> = ({ pitViewModel, onClick, style, children }) => {
|
}> = ({ pitViewModel, context, onClick, style, fontSize, children }) => {
|
||||||
|
const textColor = getColorByBrightness(
|
||||||
|
pitViewModel.pitColor,
|
||||||
|
context.themeManager.theme.textColor,
|
||||||
|
context.themeManager.theme.textLightColor
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[style, {
|
<View style={[style, {
|
||||||
backgroundColor: pitViewModel.pitColor,
|
backgroundColor: pitViewModel.pitColor,
|
||||||
borderRadius: 100,
|
borderRadius: 100,
|
||||||
//justifyItems: 'center',
|
position: 'relative'
|
||||||
}]}>
|
}]}>
|
||||||
<Pressable onPress={onClick} style={{
|
<Pressable onPress={onClick} style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
@ -28,8 +37,20 @@ const PitView: FunctionComponent<{
|
|||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
{pitViewModel.stoneCount > 0 && (
|
||||||
|
<Text style={{
|
||||||
|
color: textColor,
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: fontSize / 2,
|
||||||
|
alignSelf: 'center',
|
||||||
|
fontFamily: 'monospace',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
fontSize: fontSize
|
||||||
|
}}>
|
||||||
|
{pitViewModel.stoneCount}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user