Skip to content

Commit faf6751

Browse files
JumongwebONEONUORA
andauthored
private state (#873)
Co-authored-by: Ebube Ebuka Onuora <monweebube44@gmail.com>
1 parent 9fd09bf commit faf6751

1 file changed

Lines changed: 30 additions & 60 deletions

File tree

‎mobileapp/app/(personal)/home.tsx‎

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export default function HomeScreen() {
166166
const [refreshing, setRefreshing] = useState(false);
167167
const [notifPromptVisible, setNotifPromptVisible] = useState(false);
168168
const [notifRequesting, setNotifRequesting] = useState(false);
169+
const [balanceMasked, setBalanceMasked] = useState(true);
170+
const MASKED_BALANCE = "••••••";
169171
const earningsSheetTranslateY = useRef(new Animated.Value(48)).current;
170172
const earningsBackdropOpacity = useRef(new Animated.Value(0)).current;
171173
const shimmerAnim = useRef(new Animated.Value(-1)).current;
@@ -651,6 +653,14 @@ export default function HomeScreen() {
651653
maximumFractionDigits: 2,
652654
})}`;
653655

656+
const toggleBalanceMask = () => {
657+
void Haptics.selectionAsync().catch(() => undefined);
658+
setBalanceMasked((prev) => !prev);
659+
};
660+
661+
const displayBalance = (amount: string) =>
662+
balanceMasked ? MASKED_BALANCE : amount;
663+
654664
const monthlyEarnings = useMemo(() => {
655665
const baseTotal = MONTHLY_EARNINGS.reduce(
656666
(sum, item) => sum + item.amount,
@@ -823,47 +833,26 @@ export default function HomeScreen() {
823833
<View style={styles.balanceCard}>
824834
{/* Available Balance Section */}
825835
<View style={styles.balanceSection}>
826-
<View style={styles.balanceHeaderRow}>
836+
<View style={styles.balanceLabelRow}>
827837
<Text style={styles.balanceLabel}>Available Balance</Text>
828-
{/* Currency display toggle: ₦ fiat equivalent <-> XLM tokens */}
829-
<View style={styles.currencyToggle}>
830-
<TouchableOpacity
831-
onPress={toggleCurrency}
832-
disabled={displayCurrency === "NGN"}
833-
activeOpacity={0.7}
834-
accessibilityRole="button"
835-
accessibilityLabel="Show balance in Naira"
836-
>
837-
<Text
838-
style={[
839-
styles.currencyToggleText,
840-
displayCurrency === "NGN" &&
841-
styles.currencyToggleTextActive,
842-
]}
843-
>
844-
₦
845-
</Text>
846-
</TouchableOpacity>
847-
<TouchableOpacity
848-
onPress={toggleCurrency}
849-
disabled={displayCurrency === "XLM"}
850-
activeOpacity={0.7}
851-
accessibilityRole="button"
852-
accessibilityLabel="Show balance in XLM"
853-
>
854-
<Text
855-
style={[
856-
styles.currencyToggleText,
857-
displayCurrency === "XLM" &&
858-
styles.currencyToggleTextActive,
859-
]}
860-
>
861-
XLM
862-
</Text>
863-
</TouchableOpacity>
864-
</View>
838+
<TouchableOpacity
839+
onPress={toggleBalanceMask}
840+
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
841+
accessibilityRole="button"
842+
accessibilityLabel={
843+
balanceMasked ? "Show balance" : "Hide balance"
844+
}
845+
>
846+
<Ionicons
847+
name={balanceMasked ? "eye-outline" : "eye-off-outline"}
848+
size={20}
849+
color="#777"
850+
/>
851+
</TouchableOpacity>
865852
</View>
866-
<Text style={styles.balanceAmount}>{availableBalanceDisplay}</Text>
853+
<Text style={styles.balanceAmount}>
854+
{displayBalance(availableBalance)}
855+
</Text>
867856
</View>
868857

869858
{/* Earning Balance Section */}
@@ -873,7 +862,7 @@ export default function HomeScreen() {
873862
<Text style={styles.earningRowLabel}>Earning Balance</Text>
874863
</View>
875864
<Text style={styles.earningBalanceAmount}>
876-
{totalYieldEarnedDisplay}
865+
{displayBalance(totalYieldEarned)}
877866
</Text>
878867
</View>
879868

@@ -1780,7 +1769,7 @@ const styles = StyleSheet.create({
17801769
balanceSection: {
17811770
marginBottom: 16,
17821771
},
1783-
balanceHeaderRow: {
1772+
balanceLabelRow: {
17841773
flexDirection: "row",
17851774
alignItems: "center",
17861775
justifyContent: "space-between",
@@ -1791,25 +1780,6 @@ const styles = StyleSheet.create({
17911780
fontFamily: "Outfit_400Regular",
17921781
color: "#777",
17931782
},
1794-
currencyToggle: {
1795-
flexDirection: "row",
1796-
backgroundColor: "#F5F5F5",
1797-
borderRadius: 18,
1798-
padding: 3,
1799-
gap: 2,
1800-
},
1801-
currencyToggleText: {
1802-
fontSize: 12,
1803-
fontFamily: "Outfit_600SemiBold",
1804-
color: "#999",
1805-
paddingVertical: 4,
1806-
paddingHorizontal: 10,
1807-
borderRadius: 14,
1808-
},
1809-
currencyToggleTextActive: {
1810-
color: COLORS.secondary,
1811-
backgroundColor: COLORS.primary,
1812-
},
18131783
balanceAmount: {
18141784
fontSize: 34,
18151785
fontFamily: "Outfit_700Bold",

0 commit comments

Comments
 (0)