Add profile page

pull/24/head
Emre KARTAL 8 months ago
parent ed084dbc1b
commit 7d73e8e23a

@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x3C",
"green" : "0x3C",
"red" : "0x3C"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -12,6 +12,15 @@ struct Menu: View {
@Inject var authService: IAuthService
let parameters: [(String, String, String, String)] = [
("videoGameImage", String(localized: "drawer_create_a_bet"), String(localized: "drawer_create_a_bet_subtitle"), "CreationBet"),
("eyesImage", String(localized: "drawer_bet_history"), String(localized: "drawer_bet_history_subtitle"),"Historic"),
("friendsImage", String(localized: "drawer_friends"), String(localized: "drawer_friends_subtitle"), "Friends"),
("moneyImage", String(localized: "drawer_public_bets"), String(localized: "drawer_public_bets_subtitle"), "Bet"),
("rankingImage", String(localized: "drawer_ranking"), String(localized: "drawer_ranking_subtitle"), "Ranking"),
("eyesImage", String(localized: "drawer_current_bets"), String(localized: "drawer_current_bets_subtitle"), "Current")
]
var body: some View {
VStack(alignment: .leading, spacing: 10) {
@ -68,46 +77,13 @@ struct Menu: View {
}
.padding(.bottom, 15)
NavigationLink(destination: MainView(page: "CreationBet").navigationBarBackButtonHidden(true))
{
ParameterMenu(image: "videoGameImage", title: String(localized: "drawer_create_a_bet"), description: String(localized: "drawer_create_a_bet_subtitle"))
.padding([.leading,.trailing], 13)
}
NavigationLink(destination: MainView(page: "Historic")
.navigationBarBackButtonHidden(true))
{
ParameterMenu(image: "eyesImage", title: String(localized: "drawer_bet_history"), description: String(localized: "drawer_bet_history_subtitle"))
.padding([.leading,.trailing], 13)
}
NavigationLink(destination: MainView(page: "Friends")
.navigationBarBackButtonHidden(true))
{
ParameterMenu(image: "friendsImage", title: String(localized: "drawer_friends"), description: String(localized: "drawer_friends_subtitle"))
.padding([.leading,.trailing], 13)
}
VStack {
NavigationLink(destination: MainView(page: "Bet")
.navigationBarBackButtonHidden(true))
{
ParameterMenu(image: "moneyImage", title: String(localized: "drawer_public_bets"), description: String(localized: "drawer_public_bets_subtitle"))
.padding([.leading,.trailing], 13)
}
NavigationLink(destination: MainView(page: "Ranking").navigationBarBackButtonHidden(true))
{
ParameterMenu(image: "rankingImage", title: String(localized: "drawer_ranking"), description: String(localized: "drawer_ranking_subtitle"))
.padding([.leading,.trailing], 13)
ForEach(0..<parameters.count, id: \.self) { index in
NavigationLink(destination: MainView(page: parameters[index].3).navigationBarBackButtonHidden(true)) {
ParameterMenu(image: parameters[index].0, title: parameters[index].1, description: parameters[index].2)
.padding([.leading, .trailing], 13)
}
}
NavigationLink(destination: MainView(page: "Current").navigationBarBackButtonHidden(true))
{
ParameterMenu(image: "eyesImage", title: String(localized: "drawer_current_bets"), description: String(localized: "drawer_current_bets_subtitle"))
.padding([.leading,.trailing], 13)
}
HStack {
Spacer()
Button {
@ -120,10 +96,14 @@ struct Menu: View {
}
Spacer()
Image("gearIcon")
.resizable()
.frame(width: 30, height: 30)
.padding([.leading,.bottom], 20)
NavigationLink(destination: MainView(page: "Profile")
.navigationBarBackButtonHidden(true))
{
Image("gearIcon")
.resizable()
.frame(width: 30, height: 30)
.padding([.leading,.bottom], 20)
}
}
.frame(maxWidth: .infinity,alignment: .leading)
.background(AllInColors.primaryColor)

@ -35,6 +35,9 @@ struct AllInColors {
static let pink200 = Color("Pink200")
static let pink100 = Color("Pink100")
// Profile
static let secondaryTextColor = Color("SecondaryTextColor")
// Others
static let backgroundColor = Color("BackgroundColor")
static let darkBlueColor = Color("DarkBlueColor")

@ -56,7 +56,7 @@ class AuthService: IAuthService {
func register(username: String, email: String, password: String, completion : @escaping (Int)-> ()) {
let url = URL(string: Config.allInApi + "/users/register")!
let url = URL(string: Config.allInApi + "users/register")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

@ -48,6 +48,8 @@ struct MainView: View {
CreationBetView(showMenu: self.$showMenu)
case "Current":
CurrentBetView(showMenu: self.$showMenu)
case "Profile":
ProfileView(showMenu: self.$showMenu)
default:
BetView(showMenu: self.$showMenu)
}

@ -0,0 +1,114 @@
//
// ProfileView.swift
// AllIn
//
// Created by étudiant on 26/05/2024.
//
import SwiftUI
struct ProfileView: View {
@Binding var showMenu: Bool
let parameters: [(title: String, icon: String, backgroundColor: Color, itemColor: Color)] = [
(title: "Changer de pseudo", icon: "person", backgroundColor: AllInColors.componentBackgroundColor, itemColor: AllInColors.secondaryTextColor),
(title: "Changer le mot de passe", icon: "lock", backgroundColor: AllInColors.componentBackgroundColor, itemColor: AllInColors.secondaryTextColor),
(title: "Supprimer le compte", icon: "trash", backgroundColor: AllInColors.componentBackgroundColor, itemColor: AllInColors.secondaryTextColor),
(title: "Déconnexion", icon: "xmark", backgroundColor: AllInColors.lightPurpleColor, itemColor: .white)
]
var body: some View {
GeometryReader { geometry in
VStack(alignment: .leading, spacing: 0) {
TopBar(showMenu: self.$showMenu)
VStack(alignment: .leading) {
HStack {
Image("defaultUserImage")
.resizable()
.scaledToFit()
.frame(width: 80, height: 80)
.cornerRadius(180)
VStack(alignment: .leading, spacing: 5) {
Text("Pseudo")
.fontWeight(.bold)
.font(.system(size: 20))
HStack(spacing: 15) {
VStack(){
Text("114")
.fontWeight(.heavy)
.font(.system(size: 15))
Text(String(localized: "drawer_bets"))
.fontWeight(.regular)
.font(.system(size: 12))
.foregroundColor(AllInColors.grey600Color)
}
VStack(){
Text("343")
.fontWeight(.heavy)
.font(.system(size: 15))
Text(String(localized: "drawer_best_win"))
.fontWeight(.regular)
.font(.system(size: 12))
.foregroundColor(AllInColors.grey600Color)
}
VStack(){
Text("5")
.fontWeight(.heavy)
.font(.system(size: 15))
Text(String(localized: "drawer_nb_friends"))
.fontWeight(.regular)
.font(.system(size: 12))
.foregroundColor(AllInColors.grey600Color)
}
}
}
.padding(.leading, 10)
}
Text("Compte")
.fontWeight(.bold)
.font(.system(size: 16))
.padding(.leading, 13)
.padding(.top, 35)
VStack(spacing: 0) {
ForEach(0..<parameters.count, id: \.self) { index in
HStack {
Image(systemName: parameters[index].icon)
.foregroundColor(parameters[index].itemColor)
.padding(.leading, 13)
Text(parameters[index].title)
.font(.system(size: 14))
.fontWeight(.bold)
.foregroundColor(parameters[index].itemColor)
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(parameters[index].itemColor)
.padding(.trailing, 8)
}
.padding(.vertical, 15)
.background(parameters[index].backgroundColor)
}
}
.frame(maxWidth: .infinity)
.cornerRadius(7)
Spacer()
}
.padding(.top, geometry.size.width*0.15)
.padding(.horizontal, 20)
}
.edgesIgnoringSafeArea(.bottom).background(AllInColors.backgroundColor)
}
}
}
struct ProfileView_Previews: PreviewProvider {
static var previews: some View {
ProfileView(showMenu: .constant(false))
}
}

@ -79,6 +79,7 @@
ECB7BC702B336E28002A6654 /* RegisterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECB7BC6F2B336E28002A6654 /* RegisterViewModel.swift */; };
ECCD244A2B4DE8010071FA9E /* Api in Frameworks */ = {isa = PBXBuildFile; productRef = ECCD24492B4DE8010071FA9E /* Api */; };
ECDDD48A2BF4A7920009223A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = ECDDD48C2BF4A7920009223A /* Localizable.strings */; };
ECDDD48F2C034A420009223A /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECDDD48E2C034A420009223A /* ProfileView.swift */; };
ECED90B52B6D9CEC00F50937 /* DailyGiftPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECED90B42B6D9CEC00F50937 /* DailyGiftPage.swift */; };
ECF872662B9266C000F9D240 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ECF872652B9266C000F9D240 /* WidgetKit.framework */; };
ECF872682B9266C000F9D240 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ECF872672B9266C000F9D240 /* SwiftUI.framework */; };
@ -218,6 +219,7 @@
ECB7BC6F2B336E28002A6654 /* RegisterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterViewModel.swift; sourceTree = "<group>"; };
ECDDD48B2BF4A7920009223A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
ECDDD48D2BF4A7970009223A /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
ECDDD48E2C034A420009223A /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
ECED90B42B6D9CEC00F50937 /* DailyGiftPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailyGiftPage.swift; sourceTree = "<group>"; };
ECF872642B9266C000F9D240 /* AllInWidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = AllInWidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
ECF872652B9266C000F9D240 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
@ -393,6 +395,7 @@
123225D82B67B46100D30BB3 /* BetEndingValidationView.swift */,
EC17A15D2B6A955E008A8679 /* CurrentBetView.swift */,
ECED90B42B6D9CEC00F50937 /* DailyGiftPage.swift */,
ECDDD48E2C034A420009223A /* ProfileView.swift */,
);
path = Views;
sourceTree = "<group>";
@ -680,6 +683,7 @@
ECB7BC702B336E28002A6654 /* RegisterViewModel.swift in Sources */,
EC17A1602B6A9781008A8679 /* CurrentBetViewModel.swift in Sources */,
EC650A4C2B25E9C7003AFCAD /* RankingView.swift in Sources */,
ECDDD48F2C034A420009223A /* ProfileView.swift in Sources */,
EC9464E92B7413E1004EEBD8 /* BetEndingValidationViewModel.swift in Sources */,
EC7A882B2B28D1E0004F226A /* DropDownMenu.swift in Sources */,
EC7A882D2B28D8A1004F226A /* CreationBetView.swift in Sources */,

Loading…
Cancel
Save