Skip to content

Commit

Permalink
refactor: code formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandram-Dutta committed Jan 7, 2024
1 parent 6b28424 commit 68b35c6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
33 changes: 19 additions & 14 deletions VITTY/VITTY/Core/Community/Search/Views/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct SearchView: View {
@Environment(\.dismiss) var dismiss
var body: some View {
Group {
VStack(alignment: .center){
VStack(alignment: .center) {
HStack {
Button(action: {
dismiss()
Expand Down Expand Up @@ -48,16 +48,17 @@ struct SearchView: View {
.foregroundColor(Color.theme.tfBlue)
}
)

}

}.padding(.vertical)
}
.padding(.vertical)
if loading {
Spacer()
ProgressView()
} else {

}
else {

ForEach(searchedFriends, id: \.username) { friend in
AddFriendCard(friend: friend)
}
Expand All @@ -66,35 +67,39 @@ struct SearchView: View {
}
.padding()
.background(
Image( "HomeBG"
)
Image(
"HomeBG"
)
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
)
}
}
func search () {

func search() {
loading = true
let url = URL(string: "\(APIConstants.base_url)/api/v2/users/search?query=\(searchText)")!
let url = URL(string: "\(APIConstants.base_url)/api/v2/users/search?query=\(searchText)")!
var request = URLRequest(url: url)
let session = URLSession.shared
request.httpMethod = "GET"
request.addValue("Bearer \(authState.token)", forHTTPHeaderField: "Authorization")
if searchText.isEmpty {
searchedFriends = []
} else {
}
else {
let task = session.dataTask(with: request) { (data, response, error) in
guard let data = data else {
print("No data received")
return
}
do {
// Decode the JSON data into an array of UserInfo structs
let users = try JSONDecoder().decode([Friend].self, from: data).filter {$0.username != authState.username}
let users = try JSONDecoder().decode([Friend].self, from: data)
.filter { $0.username != authState.username }
searchedFriends = users
} catch {
}
catch {
print("Error decoding JSON: \(error)")
}
}
Expand Down
32 changes: 16 additions & 16 deletions VITTY/VITTY/Core/SideMenu/View/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ struct MenuView: View {
Divider()
.padding(.top, 32)

// updateYoutStatus()

// Group {
// profile()
//
// friendCircle()
//
// friendActivity()
//
// Divider()
// }
// updateYoutStatus()

// Group {
// profile()
//
// friendCircle()
//
// friendActivity()
//
// Divider()
// }

settings()
//
// Group {
// ghostMode()
// }
// .padding(.leading)
//
// Group {
// ghostMode()
// }
// .padding(.leading)

Spacer()

Expand Down
4 changes: 2 additions & 2 deletions VITTY/VITTY/Services/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class AuthService: NSObject, ObservableObject {
case .googleSignin:
signInWithGoogle()
case .appleSignin:
signInWithApple()
// print("apple")
signInWithApple()
// print("apple")
}
}

Expand Down

0 comments on commit 68b35c6

Please sign in to comment.