Skip to content

Commit df600e8

Browse files
authored
Fixed bugs (#18)
* Fixed the following bugs: 1. Clear web cache on logout. 2. UI bug of logout button overlapping profile options on small screen at Welcome page. * Added descriptive comment
1 parent d9ee266 commit df600e8

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

AppUIComponents/LoginOptions/LoginOptionsView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ struct LoginOptionsView: View {
9292
}
9393

9494
// MARK: - Loading Overlay
95-
9695
private var loadingOverlay: some View {
9796
Color.black.opacity(0.25)
9897
.ignoresSafeArea()
@@ -247,8 +246,6 @@ struct LoginOptionsView: View {
247246
.contentShape(Rectangle())
248247
.padding(.all, theme.spacing.md)
249248
}
250-
251-
252249
}
253250

254251
extension LoginOptionsView {

AppUIComponents/Welcome/WelcomeView.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ struct WelcomeView: View {
2020

2121
// MARK: - Main body
2222
var body: some View {
23-
VStack(alignment: .center, spacing: theme.spacing.lg) {
23+
VStack(alignment: .center, spacing: theme.spacing.md) {
2424

2525
headerView()
2626

2727
makeAvailableOptionsList()
2828

2929
logoutButton()
30+
31+
Spacer()
3032
}
31-
.padding(theme.spacing.xl)
33+
.padding(.horizontal, theme.spacing.xl)
3234
.padding(.top, theme.spacing.xxl)
3335
#if !os(macOS)
3436
.navigationBarBackButtonHidden()
@@ -59,19 +61,22 @@ struct WelcomeView: View {
5961
GridItem(.flexible())
6062
]
6163

62-
ScrollView {
64+
ScrollView(showsIndicators: false) {
6365
LazyVGrid(columns: columns, spacing: theme.spacing.md) {
64-
ForEach($viewModel.options) { item in
65-
optionTile(for: item)
66+
ForEach(viewModel.options.indices, id: \.self) { index in
67+
let isLastRow = index / 2 == (viewModel.options.count - 1) / 2
68+
optionTile(for: $viewModel.options[index], isLastRow: isLastRow)
6669
}
6770
}
71+
.padding(theme.spacing.xxs)
6872
}
73+
.fixedSize(horizontal: false, vertical: true)
6974
.onPreferenceChange(TileHeightKey.self) { tileHeight = $0 }
7075
}
7176

7277
// MARK: - Option Tile
7378
@ViewBuilder
74-
private func optionTile(for item: Binding<WelcomeOptionsModel>) -> some View {
79+
private func optionTile(for item: Binding<WelcomeOptionsModel>, isLastRow: Bool = false) -> some View {
7580
let isAvailable = item.route.wrappedValue != nil
7681

7782
VStack(alignment: .leading, spacing: 0) {
@@ -102,7 +107,7 @@ struct WelcomeView: View {
102107
.inset(by: 0.5)
103108
.stroke(theme.colors.border.regular, lineWidth: 1)
104109
}
105-
.shadow(color: .black.opacity(0.08), radius: 6, x: 0, y: 2)
110+
.shadow(color: .black.opacity(0.04), radius: 3, x: 0, y: 1)
106111
.opacity(isAvailable ? 1 : 0.4)
107112
.disabled(!isAvailable)
108113
.onTapGesture {
@@ -127,7 +132,7 @@ struct WelcomeView: View {
127132
.font(.system(size: 16, weight: .semibold))
128133
.foregroundStyle(Color("262420", bundle: .main))
129134
.frame(maxWidth: .infinity, alignment: .center)
130-
.padding(.vertical, 14)
135+
.frame(height: theme.sizes.buttonHeight)
131136
}
132137
}
133138
}

AppUIComponents/Welcome/WelcomeViewModel.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@ class WelcomeViewModel: ObservableObject {
2727

2828
/// Method to perform logout
2929
func performLogout(withCompletion completion: @escaping () -> Void) {
30-
31-
_ = credentialsManager.clear()
32-
33-
completion()
30+
// Clear the web browser cookies
31+
Auth0.webAuth()
32+
.clearSession(federated: false) { [weak self] result in
33+
switch result {
34+
case .success(_):
35+
36+
// Clears the crendtials stored in keychain after the web session is successfully cleared
37+
_ = self?.credentialsManager.clear()
38+
39+
completion()
40+
break
41+
case .failure(let error):
42+
debugPrint("Error: \(error.localizedDescription)")
43+
break
44+
}
45+
}
3446
}
3547

3648
/// Method to fetch available options

0 commit comments

Comments
 (0)