Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pre-login mobile app exploration #139

Merged

Conversation

saeedbashir
Copy link
Contributor

@saeedbashir saeedbashir commented Oct 30, 2023

Description

This PR add's support for pre-login exploration.

Whats Added/Removed

  • A new startup screen has been added that will be shown when the user is not signed in or Log out
  • User can go to signed In screen
  • User can go to register screen
  • User can go to discovery screen
  • User can search a course directly from the start screen
  • A link to register screen from sign in screen is removed

Here is a screen recording of the feature.

startup.screen.mp4

Note: In the second phase we will be showing the Signin and Register buttons on the discovery and course about pages and handling the relevant edge cases, like Enroll button click will redirect the user to register screen if there won't be a session.

@codecov
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (develop@1296cb9). Click here to learn what that means.

❗ Current head 06cf408 differs from pull request most recent head 3d31b0c. Consider uploading reports for the commit 3d31b0c to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##             develop   #139   +/-   ##
========================================
  Coverage           ?      0           
========================================
  Files              ?      0           
  Lines              ?      0           
  Branches           ?      0           
========================================
  Hits               ?      0           
  Misses             ?      0           
  Partials           ?      0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@saeedbashir saeedbashir requested a review from mumer92 November 3, 2023 10:06
@mumer92
Copy link
Contributor

mumer92 commented Nov 8, 2023

@saeedbashir please resolve the conflicts.

@touchapp touchapp requested review from k1rill and rnr and removed request for k1rill November 20, 2023 14:09
@saeedbashir saeedbashir force-pushed the saeed/pre_login_exploration branch from de87866 to 38cbec7 Compare November 22, 2023 05:36
@saeedbashir
Copy link
Contributor Author

@rnr @volodymyr-chekyrta Can you guys please review this PR? it's resulting in conflicts again and again.

@@ -29,6 +30,20 @@ public struct SignInView: View {
.resizable()
.edgesIgnoringSafeArea(.top)
}.frame(maxWidth: .infinity, maxHeight: 200)
let config = Container.shared.resolve(ConfigProtocol.self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this break the Preview?
It would be better to pass dependencies to SignInView init or ViewModel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, now using it from the viewModel.

Comment on lines 121 to 131
try? await interactor.logOut()
router.showLoginScreen()
analytics.userLogout(force: false)
do {
try await interactor.logOut()
router.showStartupScreen()
analytics.userLogout(force: false)
} catch let error {
if error.isInternetError {
errorMessage = CoreLocalization.Error.slowOrNoInternetConnection
} else {
errorMessage = CoreLocalization.Error.unknownError
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to keep that logic; it's done on purpose.
We must ignore server response for logout for offline and deprecated version cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this gets changed. I'd only change the method. Reverted the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Maybe some merge issue. idk

@@ -41,7 +41,7 @@ struct MainScreenView: View {
var body: some View {
TabView(selection: $selection) {
ZStack {
DiscoveryView(viewModel: Container.shared.resolve(DiscoveryViewModel.self)!)
DiscoveryView(viewModel: Container.shared.resolve(DiscoveryViewModel.self)!, router: Container.shared.resolve(DiscoveryRouter.self)!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

133 Characters line.
We have to limit it to 80-120 characters.

Let's format it to

DiscoveryView(
    viewModel: Container.shared.resolve(DiscoveryViewModel.self)!, 
    router: Container.shared.resolve(DiscoveryRouter.self)!
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are partially trying to follow this convention
https://google.github.io/swift/#function-calls
When a function call is line-wrapped, each argument is written on its own line.

I know we have places in the project with different formatting, but I hope to follow this one for all new written code.

Could you please format it to this style?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, new XCode code formatting Control + M also format code this way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip but I guess the way Control + M is formatting we are not following that format in the code base. This is how Control + M formatted the above lines
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right; it's doing a bit too much 😂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But just the main point that I wanted to mention is
When a function call is line-wrapped, each argument is written on its own line.
@rnr @eyatsenkoperpetio FYI

@saeedbashir
Copy link
Contributor Author

Yes, it's about the script, please check that you have this commit 1296cb9

Done

@volodymyr-chekyrta
Copy link
Contributor

I need a little more time for review; I have a few concerns, trying to understand them.

@saeedbashir, could you please help me? Seems I'm missing something.
Why do you open the Discovery screen to open the Search screen rather than just opening the Search screen?
I'm not entirely sure, it may seem like an unnecessary extra step, but I don't want to risk misunderstanding the concept.

@saeedbashir
Copy link
Contributor Author

Why do you open the Discovery screen to open the Search screen rather than just opening the Search screen?

@volodymyr-chekyrta It's because I'm building the whole flow so that when the user comes back from the search, the discovery will be there.

@volodymyr-chekyrta
Copy link
Contributor

Why do you open the Discovery screen to open the Search screen rather than just opening the Search screen?

@volodymyr-chekyrta It's because I'm building the whole flow so that when the user comes back from the search, the discovery will be there.

Android appears to have adopted a similar flow, so is this a typical user experience expectation?

@saeedbashir
Copy link
Contributor Author

Why do you open the Discovery screen to open the Search screen rather than just opening the Search screen?

@volodymyr-chekyrta It's because I'm building the whole flow so that when the user comes back from the search, the discovery will be there.

Android appears to have adopted a similar flow, so is this a typical user experience expectation?

Yes.

@volodymyr-chekyrta
Copy link
Contributor

Why do you open the Discovery screen to open the Search screen rather than just opening the Search screen?

@volodymyr-chekyrta It's because I'm building the whole flow so that when the user comes back from the search, the discovery will be there.

Android appears to have adopted a similar flow, so is this a typical user experience expectation?

Yes.

Thank you, got it. I'll provide a few more comments based on this flow

@@ -19,6 +19,7 @@ public class DiscoveryViewModel: ObservableObject {

@Published var courses: [CourseItem] = []
@Published var showError: Bool = false
@Published var searchQuery: String?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@published is redundant here because this variable does not affect UI changes.
Btw, the DiscoveryViewModel doesn't use this; maybe we can move it to the DiscoveryView?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. moved to DiscoveryView.

@saeedbashir
Copy link
Contributor Author

@volodymyr-chekyrta I've made all the highlighted changes, It's ready for another pass.

@volodymyr-chekyrta
Copy link
Contributor

The code looks good to me 👍
But I found one bug or part of missed logic.

When trying to enroll in a course, the user sees an error message.
I understand this is because the user is unauthorized, but maybe we can handle this scenario by redirecting him to log in or just hiding the "Enroll" button.

Simulator.Screen.Recording.-.iPhone.14.-.2023-11-30.at.11.04.04.mp4

@saeedbashir
Copy link
Contributor Author

saeedbashir commented Nov 30, 2023

The code looks good to me 👍 But I found one bug or part of missed logic.

When trying to enroll in a course, the user sees an error message. I understand this is because the user is unauthorized, but maybe we can handle this scenario by redirecting him to log in or just hiding the "Enroll" button.

Simulator.Screen.Recording.-.iPhone.14.-.2023-11-30.at.11.04.04.mp4

We will be doing that in the second phase. In the second phase, we will be showing the Signin and Register buttons on the discovery and course about pages and will redirect the user to the register screen if the user hits on the Enroll button without signin.

I've added a note for second phase in the PR description.

@volodymyr-chekyrta
Copy link
Contributor

The code looks good to me 👍 But I found one bug or part of missed logic.
When trying to enroll in a course, the user sees an error message. I understand this is because the user is unauthorized, but maybe we can handle this scenario by redirecting him to log in or just hiding the "Enroll" button.
Simulator.Screen.Recording.-.iPhone.14.-.2023-11-30.at.11.04.04.mp4

We will be doing that in the second phase. In the second phase, we will be showing the Signin and Register buttons on the discovery and course about pages and will redirect the user to the register screen if the user hits on the Enroll button without signin.

I've added a note for second phase in the PR description.

Got it, thank you!

@volodymyr-chekyrta
Copy link
Contributor

Looks good to me and is ready to merge 👍
The last concern is still about the Config file.
On GitHub, on the "Files сhanged" page I see the old Config file.
It looks like a wrong merge or something, could we please double-check it before merging?

Screenshot 2023-12-01 at 17 33 58 Screenshot 2023-12-01 at 17 34 32

@saeedbashir
Copy link
Contributor Author

The following image is from my branch, and the config is latest. I'm not sure why it's showing an old copy to you. Can you please checkout my branch and see which config class you see?

Screenshot 2023-12-01 at 8 48 31 PM

@volodymyr-chekyrta
Copy link
Contributor

The following image is from my branch, and the config is latest. I'm not sure why it's showing an old copy to you. Can you please checkout my branch and see which config class you see?

I found it. It's file in the folder, and it's not connected to the XCode proj.
Could you please delete it?

Screenshot 2023-12-01 at 18 14 55

@saeedbashir
Copy link
Contributor Author

Could you please delete it?

Sure, I've removed it.

@volodymyr-chekyrta
Copy link
Contributor

Could you please delete it?

Sure, I've removed it.

The last commit is from November 24, could you please make sure you pushed the new one?

@saeedbashir
Copy link
Contributor Author

The last commit is from November 24, could you please make sure you pushed the new one?

I've deleted it under this commit, 3d31b0c

@volodymyr-chekyrta volodymyr-chekyrta merged commit ec53c4c into openedx:develop Dec 2, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants