Add SimpleHeader to all screens and fix Connect Wallet

- Enable SimpleHeader with back button for all 27+ screens
- Fix Connect Wallet: check if accounts exist, navigate to WalletSetup if not
- Use Kurdish (Kurmanci) for alert messages instead of Turkish
- DashboardScreen: use handleConnectWallet with proper logic
- AppsScreen: same connect wallet logic as ReferralScreen
This commit is contained in:
2026-01-17 02:30:01 +03:00
parent 0f29a3309d
commit 267e21d0ff
3 changed files with 166 additions and 36 deletions
+139 -30
View File
@@ -5,6 +5,7 @@ import { NavigationContainer } from '@react-navigation/native';
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
import { useAuth } from '../contexts/AuthContext'; // Import useAuth import { useAuth } from '../contexts/AuthContext'; // Import useAuth
import { KurdistanColors } from '../theme/colors'; import { KurdistanColors } from '../theme/colors';
import { SimpleHeader } from '../components/navigation/SharedHeader';
// Screens // Screens
import WelcomeScreen from '../screens/WelcomeScreen'; import WelcomeScreen from '../screens/WelcomeScreen';
@@ -147,14 +148,18 @@ const AppNavigator: React.FC = () => {
component={SettingsScreen} component={SettingsScreen}
options={{ options={{
presentation: 'modal', presentation: 'modal',
headerShown: false, headerShown: true,
headerTitle: 'Settings',
header: (props) => <SimpleHeader {...props} />,
}} }}
/> />
<Stack.Screen <Stack.Screen
name="BeCitizenChoice" name="BeCitizenChoice"
component={BeCitizenChoiceScreen} component={BeCitizenChoiceScreen}
options={{ options={{
headerShown: false, headerShown: true,
headerTitle: 'Citizenship',
header: (props) => <SimpleHeader {...props} />,
}} }}
/> />
<Stack.Screen <Stack.Screen
@@ -179,149 +184,253 @@ const AppNavigator: React.FC = () => {
name="EditProfile" name="EditProfile"
component={EditProfileScreen} component={EditProfileScreen}
options={{ options={{
headerShown: false, headerShown: true,
headerTitle: 'Edit Profile',
header: (props) => <SimpleHeader {...props} />,
}} }}
/> />
<Stack.Screen <Stack.Screen
name="Wallet" name="Wallet"
component={WalletScreen} component={WalletScreen}
options={{ options={{
headerShown: false, headerShown: true,
headerTitle: 'Wallet',
header: (props) => <SimpleHeader {...props} />,
}} }}
/> />
<Stack.Screen <Stack.Screen
name="WalletSetup" name="WalletSetup"
component={WalletSetupScreen} component={WalletSetupScreen}
options={{ options={{
headerShown: false, headerShown: true,
headerTitle: 'Wallet Setup',
header: (props) => <SimpleHeader {...props} />,
}} }}
/> />
<Stack.Screen <Stack.Screen
name="Swap" name="Swap"
component={SwapScreen} component={SwapScreen}
options={{ options={{
headerShown: false, headerShown: true,
headerTitle: 'Swap',
header: (props) => <SimpleHeader {...props} />,
}} }}
/> />
<Stack.Screen <Stack.Screen
name="P2P" name="P2P"
component={P2PScreen} component={P2PScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'P2P Market',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Forum" name="Forum"
component={ForumScreen} component={ForumScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Forum',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="TaxZekat" name="TaxZekat"
component={TaxZekatScreen} component={TaxZekatScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Tax & Zekat',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Launchpad" name="Launchpad"
component={LaunchpadScreen} component={LaunchpadScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Launchpad',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="President" name="President"
component={PresidentScreen} component={PresidentScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Serok',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Vote" name="Vote"
component={VoteScreen} component={VoteScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Vote',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Validators" name="Validators"
component={ValidatorsScreen} component={ValidatorsScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Validators',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Proposals" name="Proposals"
component={ProposalsScreen} component={ProposalsScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Proposals',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Identity" name="Identity"
component={IdentityScreen} component={IdentityScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Identity',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="KurdMedia" name="KurdMedia"
component={KurdMediaScreen} component={KurdMediaScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'KurdMedia',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Perwerde" name="Perwerde"
component={PerwerdeScreen} component={PerwerdeScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Perwerde',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="B2B" name="B2B"
component={B2BScreen} component={B2BScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'B2B Marketplace',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Bank" name="Bank"
component={BankScreen} component={BankScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Bank',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Assembly" name="Assembly"
component={AssemblyScreen} component={AssemblyScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Assembly',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Justice" name="Justice"
component={JusticeScreen} component={JusticeScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Justice',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Polls" name="Polls"
component={PollsScreen} component={PollsScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Polls',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="WhatsKURD" name="WhatsKURD"
component={WhatsKURDScreen} component={WhatsKURDScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'whatsKURD',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Events" name="Events"
component={EventsScreen} component={EventsScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Events',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Help" name="Help"
component={HelpScreen} component={HelpScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Help',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Music" name="Music"
component={MusicScreen} component={MusicScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Music',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="VPN" name="VPN"
component={VPNScreen} component={VPNScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'VPN',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="University" name="University"
component={UniversityScreen} component={UniversityScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'University',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Certificates" name="Certificates"
component={CertificatesScreen} component={CertificatesScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Certificates',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
<Stack.Screen <Stack.Screen
name="Research" name="Research"
component={ResearchScreen} component={ResearchScreen}
options={{ headerShown: false }} options={{
headerShown: true,
headerTitle: 'Research',
header: (props) => <SimpleHeader {...props} />,
}}
/> />
</> </>
)} )}
+9 -3
View File
@@ -72,7 +72,7 @@ const CATEGORIES: { name: CategoryType; icon: string }[] = [
const AppsScreen: React.FC = () => { const AppsScreen: React.FC = () => {
const navigation = useNavigation<any>(); const navigation = useNavigation<any>();
const { selectedAccount, connectWallet } = usePezkuwi(); const { selectedAccount, accounts, connectWallet } = usePezkuwi();
const isConnected = !!selectedAccount; const isConnected = !!selectedAccount;
const [searchQuery, setSearchQuery] = useState(''); const [searchQuery, setSearchQuery] = useState('');
@@ -94,12 +94,18 @@ const AppsScreen: React.FC = () => {
}); });
const handleConnectWallet = async () => { const handleConnectWallet = async () => {
// If no wallets exist, navigate to wallet setup first
if (accounts.length === 0) {
navigation.navigate('WalletSetup');
return;
}
try { try {
await connectWallet(); await connectWallet();
Alert.alert('Connected', 'Your wallet has been connected successfully!'); Alert.alert('Girêdayî / Connected', 'Cîzdanê te bi serkeftî girêdayî bû!\nYour wallet has been connected successfully!');
} catch (error) { } catch (error) {
if (__DEV__) console.error('Wallet connection error:', error); if (__DEV__) console.error('Wallet connection error:', error);
Alert.alert('Error', 'Failed to connect wallet. Please try again.'); Alert.alert('Çewtî / Error', 'Cîzdan nehat girêdan. Dîsa biceribîne.\nFailed to connect wallet. Please try again.');
} }
}; };
+18 -3
View File
@@ -84,7 +84,7 @@ interface DashboardScreenProps {}
const DashboardScreen: React.FC<DashboardScreenProps> = () => { const DashboardScreen: React.FC<DashboardScreenProps> = () => {
const navigation = useNavigation<NavigationProp<BottomTabParamList & RootStackParamList>>(); const navigation = useNavigation<NavigationProp<BottomTabParamList & RootStackParamList>>();
const { user } = useAuth(); const { user } = useAuth();
const { api, isApiReady, selectedAccount } = usePezkuwi(); const { api, isApiReady, selectedAccount, accounts, connectWallet } = usePezkuwi();
const [profileData, setProfileData] = useState<any>(null); const [profileData, setProfileData] = useState<any>(null);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [avatarModalVisible, setAvatarModalVisible] = useState(false); const [avatarModalVisible, setAvatarModalVisible] = useState(false);
@@ -167,6 +167,21 @@ const DashboardScreen: React.FC<DashboardScreenProps> = () => {
// Check if user is a visitor (default when no blockchain wallet or no tikis) // Check if user is a visitor (default when no blockchain wallet or no tikis)
const isVisitor = !selectedAccount || tikis.length === 0; const isVisitor = !selectedAccount || tikis.length === 0;
// Handle wallet connection
const handleConnectWallet = async () => {
if (accounts.length === 0) {
navigation.navigate('WalletSetup');
return;
}
try {
await connectWallet();
Alert.alert('Girêdayî / Connected', 'Cîzdanê te bi serkeftî girêdayî bû!\nYour wallet has been connected successfully!');
} catch (error) {
if (__DEV__) console.error('Wallet connection error:', error);
Alert.alert('Çewtî / Error', 'Cîzdan nehat girêdan.\nFailed to connect wallet.');
}
};
const primaryRole = tikis.length > 0 ? getPrimaryRole(tikis) : 'Visitor'; const primaryRole = tikis.length > 0 ? getPrimaryRole(tikis) : 'Visitor';
const showComingSoon = (featureName: string) => { const showComingSoon = (featureName: string) => {
@@ -463,10 +478,10 @@ const DashboardScreen: React.FC<DashboardScreenProps> = () => {
{!selectedAccount && ( {!selectedAccount && (
<TouchableOpacity <TouchableOpacity
style={styles.connectWalletBadge} style={styles.connectWalletBadge}
onPress={() => navigation.navigate('Wallet')} onPress={handleConnectWallet}
> >
<Text style={styles.connectWalletIcon}>👛</Text> <Text style={styles.connectWalletIcon}>👛</Text>
<Text style={styles.connectWalletText}>Connect</Text> <Text style={styles.connectWalletText}>Girêde</Text>
</TouchableOpacity> </TouchableOpacity>
)} )}
</View> </View>