Skip to content

Commit

Permalink
fix id cairo + side auth + typo
Browse files Browse the repository at this point in the history
  • Loading branch information
MSghais committed Aug 21, 2024
1 parent 2c25034 commit 4b93181
Show file tree
Hide file tree
Showing 24 changed files with 284 additions and 178 deletions.
116 changes: 71 additions & 45 deletions apps/mobile/src/app/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {useAuth} from 'afk_nostr_sdk';
import {useEffect, useMemo, useState} from 'react';
import {Dimensions, Platform, StyleSheet, useWindowDimensions, View} from 'react-native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { useAuth } from 'afk_nostr_sdk';
import { useEffect, useMemo, useState } from 'react';
import { Dimensions, Platform, StyleSheet, useWindowDimensions, View } from 'react-native';

import {Icon} from '../components';
import {Navbar} from '../components/Navbar';
import {useStyles, useTheme} from '../hooks';
import { Icon } from '../components';
import { Navbar } from '../components/Navbar';
import { useStyles, useTheme } from '../hooks';
import Sidebar from '../modules/Layout/sidebar';
import {CreateAccount} from '../screens/Auth/CreateAccount';
import {ImportKeys} from '../screens/Auth/ImportKeys';
import {Login} from '../screens/Auth/Login';
import {SaveKeys} from '../screens/Auth/SaveKeys';
import {ChannelDetail} from '../screens/ChannelDetail';
import {ChannelsFeed} from '../screens/ChannelsFeed';
import {CreateChannel} from '../screens/CreateChannel';
import {CreateForm} from '../screens/CreateForm';
import {CreatePost} from '../screens/CreatePost';
import {Defi} from '../screens/Defi';
import {EditProfile} from '../screens/EditProfile';
import {Feed} from '../screens/Feed';
import {Games} from '../screens/Games';
import {LaunchDetail} from '../screens/LaunchDetail';
import {PostDetail} from '../screens/PostDetail';
import {Profile} from '../screens/Profile';
import {Search} from '../screens/Search';
import {Settings} from '../screens/Settings';
import {Tips} from '../screens/Tips';
import {ThemedStyleSheet} from '../styles';
import {AuthStackParams, HomeBottomStackParams, MainStackParams, RootStackParams} from '../types';
import {retrievePublicKey} from '../utils/storage';
import AuthSidebar from '../modules/Layout/auth-sidebar';
import { CreateAccount } from '../screens/Auth/CreateAccount';
import { ImportKeys } from '../screens/Auth/ImportKeys';
import { Login } from '../screens/Auth/Login';
import { SaveKeys } from '../screens/Auth/SaveKeys';
import { ChannelDetail } from '../screens/ChannelDetail';
import { ChannelsFeed } from '../screens/ChannelsFeed';
import { CreateChannel } from '../screens/CreateChannel';
import { CreateForm } from '../screens/CreateForm';
import { CreatePost } from '../screens/CreatePost';
import { Defi } from '../screens/Defi';
import { EditProfile } from '../screens/EditProfile';
import { Feed } from '../screens/Feed';
import { Games } from '../screens/Games';
import { LaunchDetail } from '../screens/LaunchDetail';
import { PostDetail } from '../screens/PostDetail';
import { Profile } from '../screens/Profile';
import { Search } from '../screens/Search';
import { Settings } from '../screens/Settings';
import { Tips } from '../screens/Tips';
import { ThemedStyleSheet } from '../styles';
import { AuthStackParams, HomeBottomStackParams, MainStackParams, RootStackParams } from '../types';
import { retrievePublicKey } from '../utils/storage';

const DrawerStack = createDrawerNavigator<MainStackParams>();
const RootStack = createNativeStackNavigator<RootStackParams>();
const AuthStack = createNativeStackNavigator<AuthStackParams>();
const AuthStack = createDrawerNavigator<AuthStackParams>();
// const AuthStack = createNativeStackNavigator<AuthStackParams>();
const MainStack = createNativeStackNavigator<MainStackParams>();
const HomeBottomTabsStack = createBottomTabNavigator<HomeBottomStackParams>();

const HomeBottomTabNavigator: React.FC = () => {
const styles = useStyles(stylesheet);

const {publicKey} = useAuth();
const {theme} = useTheme();
const { publicKey } = useAuth();
const { theme } = useTheme();

return (
<HomeBottomTabsStack.Navigator
Expand All @@ -60,7 +62,7 @@ const HomeBottomTabNavigator: React.FC = () => {
options={{
tabBarActiveTintColor: 'white',
tabBarInactiveTintColor: theme.colors.background,
tabBarIcon: ({focused}) => (
tabBarIcon: ({ focused }) => (
<View style={styles.tabBarIcon}>
<Icon
name="HomeIcon"
Expand All @@ -79,7 +81,7 @@ const HomeBottomTabNavigator: React.FC = () => {
options={{
tabBarActiveTintColor: 'white',
tabBarInactiveTintColor: 'grey',
tabBarIcon: ({focused}) => (
tabBarIcon: ({ focused }) => (
<View style={styles.tabBarIcon}>
<Icon
name="CoinIcon"
Expand All @@ -99,7 +101,7 @@ const HomeBottomTabNavigator: React.FC = () => {
options={{
tabBarActiveTintColor: 'white',
tabBarInactiveTintColor: 'grey',
tabBarIcon: ({focused}) => (
tabBarIcon: ({ focused }) => (
<View style={styles.tabBarIcon}>
<Icon
name="GameIcon"
Expand All @@ -116,11 +118,11 @@ const HomeBottomTabNavigator: React.FC = () => {
<HomeBottomTabsStack.Screen
name="UserProfile"
component={Profile as any}
initialParams={{publicKey}}
initialParams={{ publicKey }}
options={{
tabBarActiveTintColor: 'white',
tabBarInactiveTintColor: 'grey',
tabBarIcon: ({focused}) => (
tabBarIcon: ({ focused }) => (
<View style={styles.tabBarIcon}>
<Icon
name="UserIcon"
Expand All @@ -141,7 +143,7 @@ const HomeBottomTabNavigator: React.FC = () => {
options={{
tabBarActiveTintColor: 'white',
tabBarInactiveTintColor: 'grey',
tabBarIcon: ({focused}) => (
tabBarIcon: ({ focused }) => (
<View style={styles.tabBarIcon}>
<Icon
name="UserIcon"
Expand All @@ -160,6 +162,12 @@ const HomeBottomTabNavigator: React.FC = () => {

const AuthNavigator: React.FC = () => {
const [publicKey, setPublicKey] = useState<string | null | undefined>(undefined);
const dimensions = useWindowDimensions();
const isDesktop = useMemo(() => {
return dimensions.width >= 1024;
}, [dimensions]); // Adjust based on your breakpoint for desktop

const theme = useTheme();

useEffect(() => {
retrievePublicKey().then((key) => {
Expand All @@ -170,7 +178,25 @@ const AuthNavigator: React.FC = () => {
if (publicKey === undefined) return null;

return (
<AuthStack.Navigator screenOptions={{headerShown: false}}>
<AuthStack.Navigator
drawerContent={(props) => <AuthSidebar navigation={props?.navigation}></AuthSidebar>}
screenOptions={({ navigation }) => ({
// headerShown:false,
// header: () => <Navbar navigation={navigation} title="AFK" showLogo={true} />,
headerShown:false,
headerStyle: {
backgroundColor: theme.theme.colors.background,
},
drawerType: isDesktop ? 'permanent' : 'front',
// drawerType:"permanent",
headerTintColor: theme.theme.colors.text,
overlayColor: isDesktop ? 'transparent' : theme.theme.colors.background, // Make sure overlay settings are correct
// swipeEdgeWidth: 0
drawerStyle: {
width: "25%", // Adjust width or other styling as necessary
},
})}
>
{publicKey && <AuthStack.Screen name="Login" component={Login} />}
<AuthStack.Screen name="CreateAccount" component={CreateAccount} />
<AuthStack.Screen name="SaveKeys" component={SaveKeys} />
Expand All @@ -192,7 +218,7 @@ const MainNavigator: React.FC = () => {
// screenOptions={{ headerShown: false }}
// initialRouteName="Home"
drawerContent={(props) => <Sidebar navigation={props?.navigation}></Sidebar>}
screenOptions={({navigation}) => ({
screenOptions={({ navigation }) => ({
// headerShown:false,
header: () => <Navbar navigation={navigation} title="AFK" showLogo={true} />,
headerStyle: {
Expand Down Expand Up @@ -282,10 +308,10 @@ const linking = {
};

const RootNavigator: React.FC = () => {
const {publicKey} = useAuth();
const { publicKey } = useAuth();

return (
<RootStack.Navigator screenOptions={{headerShown: false}}>
<RootStack.Navigator screenOptions={{ headerShown: false }}>
{/* <RootStack.Screen name="MainStack" component={MainNavigator} /> */}
{publicKey ? (
<RootStack.Screen name="MainStack" component={MainNavigator} />
Expand Down
47 changes: 47 additions & 0 deletions apps/mobile/src/modules/Layout/auth-sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { useEffect } from 'react';
import { Text, View } from 'react-native';
import { useStyles, useTheme } from '../../../hooks';
import stylesheet from './styles';

interface SidebarInterface {
navigation: any;
}
const AuthSidebar = ({ navigation }: SidebarInterface) => {
const styles = useStyles(stylesheet);

useEffect(() => {
const unsubscribe = navigation.addListener('drawerClose', () => {
// Code to handle drawer closing
});

return unsubscribe;
}, [navigation]);

return (
<View style={styles.sidebar}>
<Text style={styles.sidebarText}>AFK: Aligned Fam Kernel</Text>

<View style={styles.container}>
<Text style={styles.title}>All-in-one platform</Text>

</View>


<View style={styles.container}>
<Text style={styles.textItem}>Connect or create an Account</Text>
<Text style={styles.textItem}>Acces the AFK app</Text>

Check warning on line 32 in apps/mobile/src/modules/Layout/auth-sidebar/index.tsx

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Acces" should be "Access".
</View>

<View style={styles.container}>
<Text style={styles.textItem}>Coming soon also in IOS and Android</Text>

<View style={{flex:1, flexDirection:"row"}}>

</View>
</View>

</View>
);
};

export default AuthSidebar;
86 changes: 86 additions & 0 deletions apps/mobile/src/modules/Layout/auth-sidebar/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import {Spacing, ThemedStyleSheet} from '../../../styles';

export default ThemedStyleSheet((theme) => ({
container: {
marginVertical:10,
color: theme.colors.text,
},
sidebar: {
width: '100%',
height: '100%',
backgroundColor: theme.colors.background,
padding: 10,
gap: 1,
// borderRight:"1"
},
sidebarText: {
fontSize: 18,
color: theme.colors.text,
},
title: {
fontWeight: 'bold',
marginBottom: 16,
color: theme.colors.text,
},
item: {
display: 'flex',
width: '100%',
height: 100,
backgroundColor: theme.colors.background,
// flex
// flex: 1,
flexDirection: 'row',
// paddingVertical: 8,
color: theme.colors.text,
},
textItem: {
backgroundColor: theme.colors.background,
color: theme.colors.text,
},
outsideContainer: {
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
width: '100%',
height: '100%',
},

outside: {
width: '100%',
height: '100%',
},

menuContainer: {
position: 'absolute',
zIndex: 1,
},
menu: {
position: 'absolute',
height: 'auto',
backgroundColor: theme.colors.divider,
borderRadius: 16,
overflow: 'hidden',
shadowColor: theme.colors.shadow,
shadowOffset: {width: 0, height: 2},
shadowRadius: 4,
elevation: 2,
},

menuItem: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
gap: Spacing.xxsmall,
backgroundColor: theme.colors.surface,
paddingHorizontal: Spacing.medium,
paddingVertical: Spacing.small,
},
menuItemLabel: {
flex: 1,
fontSize: 17,
lineHeight: 22,
color: theme.colors.text,
},
}));
1 change: 0 additions & 1 deletion apps/mobile/src/modules/Layout/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const Sidebar = ({navigation}: SidebarInterface) => {
return (
<View style={styles.sidebar}>
<Text style={styles.sidebarText}>AFK</Text>
<Text style={styles.title}>Features coming soon</Text>
{/*
<Text style={[styles.item]}>
Launchpad
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/modules/Layout/sidebar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export default ThemedStyleSheet((theme) => ({
backgroundColor: theme.colors.background,
padding: 20,
gap: 1,
color: theme.colors.text,

// borderRight:"1"
},
sidebarText: {
Expand Down
25 changes: 9 additions & 16 deletions onchain/cairo/src/afk_id/afk_identity.cairo
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
use afk::types::identity_types::{};
use starknet::{
ContractAddress, get_caller_address, storage_access::StorageBaseAddress,
contract_address_const, get_block_timestamp, get_contract_address, ClassHash
};

use afk::types::identity_types:: {

ContractAddress, get_caller_address, storage_access::StorageBaseAddress, contract_address_const,
get_block_timestamp, get_contract_address, ClassHash
};
#[starknet::interface]
pub trait IAfkId<T> {
}
pub trait IAfkId<T> {}

#[starknet::contract]
mod AfkIdentity {
use core::num::traits::Zero;
use starknet::{
ContractAddress, get_caller_address, storage_access::StorageBaseAddress,
contract_address_const, get_block_timestamp, get_contract_address, ClassHash
};
use core::num::traits::Zero;

#[storage]
struct Storage {
id_user_exist:LegacyMap<ContractAddress, bool>
id_user_exist: LegacyMap<ContractAddress, bool>
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
}
enum Event {}

#[abi(embed_v0)]
impl FactoryIdImpl of super::IAfkId<ContractState> {

}
impl FactoryIdImpl of super::IAfkId<ContractState> {}
}
Loading

0 comments on commit 4b93181

Please sign in to comment.