Skip to content

Commit

Permalink
Merge pull request #329 from bounswe/feature/MB-create-profile-page
Browse files Browse the repository at this point in the history
Feature/mb create profile page
  • Loading branch information
furkansenkal authored Oct 21, 2024
2 parents 3f32663 + a233a97 commit 8854329
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 14 deletions.
Binary file added mobile/assets/stock-logos/Profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/assets/stock-logos/badge-60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/assets/stock-logos/badge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 29 additions & 9 deletions mobile/src/pages/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ import Login from './Login';
import Register from './Register';
import ForgotPassword from './ForgotPassword';
import Home from './Home'
import Profile from './Profile';

const Stack = createStackNavigator();
const Sidebar = createDrawerNavigator();


const App = () => {

const CustomHeader = ({ navigation, title }) => (

const navigateProfile = (navigation, username) => {
navigation.navigate("Profile", {username: username});
};
const CustomHeader = ({ navigation, username }) => (

<View style={styles.header}>
<TouchableOpacity onPress={() => navigation.toggleDrawer()}>
<MaterialIcons name="menu" size={30} color="white" />
Expand All @@ -29,7 +34,7 @@ const App = () => {
/> */}
<Text style={styles.logoText}> Bull&Bear </Text>
</View>
<TouchableOpacity onPress={() => navigation.toggleDrawer()}>
<TouchableOpacity onPress={() => navigateProfile(navigation, username)}>
<MaterialIcons name="account-circle" size={30} color="white" />
</TouchableOpacity>
</View>
Expand All @@ -45,24 +50,39 @@ const App = () => {
)
}

return (
<NavigationContainer>
<Sidebar.Navigator>
const TabBar = (params) =>{
const username = params.route;

return(
<Sidebar.Navigator>
<Sidebar.Screen
name="Home"
component={Home}
options={({ navigation }) => ({
header: () => <CustomHeader navigation={navigation} title="Home" />,
header: () => <CustomHeader navigation={navigation} username={username} title="Home" />,
})}
/>
<Sidebar.Screen
name="Profile"
component={Profile}
options={({ navigation }) => ({
header: () => <CustomHeader navigation={navigation} username={username} title="Profile" />,
})}
/>
<Sidebar.Screen
name="Login"
name="Login&Register"
component={LoginRelated}
options={({ navigation }) => ({
header: () => <CustomHeader navigation={navigation} title="Login" />,
header: () => <CustomHeader navigation={navigation} username={username}title="Login" />,
})}
/>
</Sidebar.Navigator>
)
}

return (
<NavigationContainer>
<TabBar></TabBar>
</NavigationContainer>
);
};
Expand Down
14 changes: 10 additions & 4 deletions mobile/src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import bist50 from "../../assets/stock-logos/bist-50.png";
import bist30 from "../../assets/stock-logos/bist-30.png";
import bist from "../../assets/stock-logos/bist.png";

const Home = () => {

const Home = ({navigation, route}) => {
const username = route.params;

const posts = [
{
id: 1,
Expand Down Expand Up @@ -183,6 +184,8 @@ const Home = () => {
},
];



const renderPost = ({ item }) => (
<View style={styles.postContainer}>
<View style={styles.topContainer}>
Expand Down Expand Up @@ -219,7 +222,9 @@ const Home = () => {
);


const renderItem = ({ item }) => (
const renderItem = ({ item }) => {

return (
<View style={styles.itemContainer}>
<Image source={item.logoPath} style={styles.logo} />
<View style={styles.infoContainer}>
Expand All @@ -238,7 +243,8 @@ const Home = () => {
</Text>
</View>
</View>
);
);
};

return (
<View>
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Login = ({ navigation }) => {
if (response.ok) {
// Handle successful login
Alert.alert('Login Successful', 'Welcome!');
navigation.navigate('Home')
navigation.navigate('TabBar', {username: username})
} else {
// Handle login failure
Alert.alert('Login Failed', data.message || 'Invalid credentials');
Expand Down
174 changes: 174 additions & 0 deletions mobile/src/pages/Profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import React from 'react';
import { View, Text, Image, StyleSheet, FlatList,ScrollView, TouchableOpacity } from 'react-native';


const ProfilePage = () => {
const badges = [
{ id: 1, title: 'Highliked' },
{ id: 2, title: 'Cretagor' },

];

const portfolios = [
{
id: 1,
name: 'Tech Portfolio',
incrementRate: '15%',
stocks: ['ASELS', 'TUPRS', 'THYAO'], // Example Turkish stocks
},
{
id: 2,
name: 'Green Energy',
incrementRate: '10%',
stocks: ['ENKA', 'PETKM', 'SISE'],
},
{
id: 3,
name: 'Real Estate',
incrementRate: '5%',
stocks: ['GYO', 'EGEEN', 'KENT'],
},
];

return (
<View style={styles.container}>
{/* Profile Section */}
<View style={styles.profileContainer}>
<Image
source={require("../../assets/stock-logos/Profile.png")} // Replace with your profile image URL
style={styles.profilePhoto}
/>
<Text style={styles.username}>@YourUsername</Text>
<Text style={styles.followerCount}>Followers: 150</Text>
<TouchableOpacity >
<Text style={styles.seePost} > See posts</Text>
</TouchableOpacity>
</View>

{/* Badges Section */}
<View style={styles.badgesContainer}>
<Text style={styles.sectionTitle}>Badges</Text>
<FlatList
data={badges}
renderItem={({ item }) => (
<View style={styles.badge}>
<Image source={require("../../assets/stock-logos/badge-60.png")} height={10} width={10} resizeMode="stretch"></Image>
<Text style={styles.badgeText}>{item.title}</Text>
</View>
)}
keyExtractor={item => item.id.toString()}
horizontal
showsHorizontalScrollIndicator={false}
/>
</View>

{/* Portfolio Section */}
<ScrollView>
<View style={styles.portfolioContainer}>
<Text style={styles.sectionTitle}>My Portfolios</Text>
<FlatList
data={portfolios}
renderItem={({ item }) => (
<View style={styles.portfolioBox}>
<Text style={styles.portfolioName}>{item.name}</Text>
<View style={styles.incrementRateContainer}>
<Text style={styles.incrementRate}>{item.incrementRate}</Text>
</View>
<Text style={styles.stocksTitle}>Stocks:</Text>
<View style={styles.stockList}>
{item.stocks.map((stock, index) => (
<Text key={index} style={styles.stockText}>{stock}</Text>
))}
</View>
</View>
)}
keyExtractor={item => item.id.toString()}
/>
</View>
</ScrollView>

</View>
);
};

const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
backgroundColor: '#fff',
},
profileContainer: {
alignItems: 'center',
marginBottom: 20,
},
profilePhoto: {
width: 100,
height: 100,
borderRadius: 50,
marginBottom: 10,
},
username: {
fontSize: 20,
fontWeight: 'bold',
},
followerCount: {
fontSize: 16,
color: '#555',
},
badgesContainer: {
marginBottom: 20,
},
sectionTitle: {
fontSize: 18,
fontWeight: 'bold',
marginBottom: 10,
},
badge: {
backgroundColor: '#f0f0f0',
padding: 10,
borderRadius: 10,
marginRight: 10,
},
badgeText: {
fontSize: 14,
},
portfolioContainer: {
marginBottom: 20,
},
portfolioBox: {
backgroundColor: '#f0f0f0',
padding: 15,
borderRadius: 10,
marginVertical: 5,
},
portfolioName: {
fontSize: 16,
fontWeight: 'bold',
},
incrementRateContainer: {
flexDirection: 'row',
justifyContent: 'flex-end',
},
incrementRate: {
fontSize: 14,
color: '#28a745', // Green color for increment rate
},
stocksTitle: {
fontSize: 14,
fontWeight: 'bold',
marginTop: 10,
},
stockList: {
marginTop: 5,
},
stockText: {
fontSize: 12,
color: '#555',
},
seePost: {
color: '#005AAB',
textDecorationLine: 'underline',
},
});

export default ProfilePage;

0 comments on commit 8854329

Please sign in to comment.