Skip to content

Commit

Permalink
feat: updates after shafqat-muneer code review
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanStepanok committed Apr 30, 2024
1 parent c292ee8 commit 8069fc7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct VideoDownloadQualityContainerView: View {
VideoDownloadQualityView(
downloadQuality: downloadQuality,
didSelect: didSelect,
analytics: analytics,
analytics: analytics,
router: router
)
.navigationBarTitleDisplayMode(.inline)
Expand Down
30 changes: 15 additions & 15 deletions OpenEdX/View/MainScreenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import Theme
struct MainScreenView: View {

@State private var disableAllTabs: Bool = false
@State private var updateAvaliable: Bool = false
@State private var updateAvailable: Bool = false

@ObservedObject private(set) var viewModel: MainScreenViewModel

init(viewModel: MainScreenViewModel) {
self.viewModel = viewModel
UITabBar.appearance().isTranslucent = false
Expand All @@ -34,7 +34,7 @@ struct MainScreenView: View {
for: .normal
)
}

var body: some View {
TabView(selection: $viewModel.selection) {
let config = Container.shared.resolve(ConfigProtocol.self)
Expand All @@ -55,7 +55,7 @@ struct MainScreenView: View {
)
}

if updateAvaliable {
if updateAvailable {
UpdateNotificationView(config: viewModel.config)
}
}
Expand All @@ -72,7 +72,7 @@ struct MainScreenView: View {
viewModel: Container.shared.resolve(DashboardViewModel.self)!,
router: Container.shared.resolve(DashboardRouter.self)!
)
if updateAvaliable {
if updateAvailable {
UpdateNotificationView(config: viewModel.config)
}
}
Expand All @@ -95,7 +95,7 @@ struct MainScreenView: View {
.accessibilityIdentifier("indevelopment_program_text")
}

if updateAvaliable {
if updateAvailable {
UpdateNotificationView(config: viewModel.config)
}
}
Expand Down Expand Up @@ -124,22 +124,22 @@ struct MainScreenView: View {
.navigationTitle(titleBar())
.toolbar {
ToolbarItem(placement: .navigationBarTrailing, content: {
Button(action: {
let router = Container.shared.resolve(ProfileRouter.self)!
router.showSettings()
}, label: {
CoreAssets.settings.swiftUIImage.renderingMode(.template)
.foregroundColor(Theme.Colors.accentColor)
})
.accessibilityIdentifier("edit_profile_button")
Button(action: {
let router = Container.shared.resolve(ProfileRouter.self)!
router.showSettings()
}, label: {
CoreAssets.settings.swiftUIImage.renderingMode(.template)
.foregroundColor(Theme.Colors.accentColor)
})
.accessibilityIdentifier("edit_profile_button")
})
}
.onReceive(NotificationCenter.default.publisher(for: .onAppUpgradeAccountSettingsTapped)) { _ in
viewModel.selection = .profile
disableAllTabs = true
}
.onReceive(NotificationCenter.default.publisher(for: .onNewVersionAvaliable)) { _ in
updateAvaliable = true
updateAvailable = true
}
.onChange(of: viewModel.selection) { _ in
if disableAllTabs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ struct EditProfileView_Previews: PreviewProvider {
yearOfBirth: 0,
country: "Ukraine",
shortBiography: "",
isFullProfile: true,
isFullProfile: true,
email: "[email protected]"
)

Expand Down
18 changes: 6 additions & 12 deletions Profile/Profile/Presentation/Profile/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,18 @@ public struct ProfileView: View {
}

// MARK: - Profile Info

@ViewBuilder
private var profileInfo: some View {
if viewModel.userModel?.shortBiography != "" {
if let bio = viewModel.userModel?.shortBiography, bio != "" {
VStack(alignment: .leading, spacing: 6) {
Text(ProfileLocalization.about)
Text(ProfileLocalization.about)
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("profile_info_text")
if let bio = viewModel.userModel?.shortBiography, bio != "" {
Text(bio)
.font(Theme.Fonts.bodyMedium)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("bio_text")
}
Text(bio)
.font(Theme.Fonts.bodyMedium)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("bio_text")
}
.accessibilityElement(children: .ignore)
.accessibilityLabel(
Expand Down Expand Up @@ -202,10 +199,8 @@ struct ProfileView_Previews: PreviewProvider {
#endif

struct UserAvatar: View {

private var url: URL?
@Binding private var image: UIImage?

init(url: String, image: Binding<UIImage?>) {
if let rightUrl = URL(string: url) {
self.url = rightUrl
Expand All @@ -214,7 +209,6 @@ struct UserAvatar: View {
}
self._image = image
}

var body: some View {
ZStack {
if let image {
Expand Down
4 changes: 3 additions & 1 deletion Profile/Profile/Presentation/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public struct SettingsView: View {
viewModel.router.back()
}
)
.backViewStyle()
.backViewStyle()
.padding(.leading, isHorizontal ? 48 : 0)
.accessibilityIdentifier("back_button")

}.frame(minWidth: 0,
maxWidth: .infinity,
alignment: .topLeading)
Expand Down

0 comments on commit 8069fc7

Please sign in to comment.