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}
|
||||
pitViewModel={pitViewModel}
|
||||
onClick={() => onPitSelect(pit.index, pit)}
|
||||
style={{width: pitWidth, height: pitWidth}} >
|
||||
style={{width: pitWidth, height: pitWidth}}
|
||||
context={context}
|
||||
fontSize={pitWidth / 5}
|
||||
>
|
||||
{stones}
|
||||
</PitView>;
|
||||
};
|
||||
|
||||
@ -1,19 +1,28 @@
|
||||
import * as React from "react";
|
||||
import { FunctionComponent } from "react";
|
||||
import { PitViewModel } from "@mancala/core";
|
||||
import { Pressable, View, ViewStyle } from "react-native";
|
||||
import { PitViewModel, getColorByBrightness } from "@mancala/core";
|
||||
import { Context } from "../../context/context";
|
||||
import { Pressable, View, ViewStyle, Text } from "react-native";
|
||||
|
||||
const PitView: FunctionComponent<{
|
||||
pitViewModel: PitViewModel;
|
||||
context: Context;
|
||||
onClick: () => void;
|
||||
style: ViewStyle,
|
||||
fontSize: number;
|
||||
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 (
|
||||
<View style={[style, {
|
||||
backgroundColor: pitViewModel.pitColor,
|
||||
borderRadius: 100,
|
||||
//justifyItems: 'center',
|
||||
position: 'relative'
|
||||
}]}>
|
||||
<Pressable onPress={onClick} style={{
|
||||
width: "100%",
|
||||
@ -28,8 +37,20 @@ const PitView: FunctionComponent<{
|
||||
}}>
|
||||
{children}
|
||||
</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>
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user