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

[iOS] UI bug on iPad when using filters in Discussion #333

Merged
merged 70 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0325be9
fix: iPad register and login buttons
forgotvas Feb 26, 2024
eddb20b
fix: IPad sign up view
forgotvas Feb 26, 2024
4ecd72d
fix: iPad Course outline view
forgotvas Feb 26, 2024
a3eec7d
feat: added IPAD_STRETCH config parameter
forgotvas Feb 27, 2024
1e6b3d8
fix: size bug on small device
forgotvas Feb 27, 2024
57b54cd
fix: iPad stretch for content types
forgotvas Feb 27, 2024
37c4e27
fix: player on iPad and small devices
forgotvas Feb 27, 2024
94685e7
Merge remote-tracking branch 'upstream/develop' into feat/ipad-stretch
forgotvas Feb 27, 2024
df286b0
fix: stretch for search bar on discussions page
forgotvas Feb 27, 2024
0fd8866
fix: discussion search bar stretch
forgotvas Feb 27, 2024
9620a8d
fix: bug of player on small devices
forgotvas Feb 27, 2024
935879d
fix: removed stretching for sign up/sign in views
forgotvas Feb 27, 2024
d5f1665
feat: removed feature flag
forgotvas Feb 27, 2024
9b6b755
feat: added readable content size
forgotvas Feb 28, 2024
3fad0c5
fix: added readable content size to startup screen
forgotvas Feb 28, 2024
d1f75df
fix: sign in, sign up, reset password readable paddings
forgotvas Feb 28, 2024
c38e3a9
fix: scroll bar position for edit profile view
forgotvas Feb 28, 2024
f3eacc7
fix: social buttons
forgotvas Feb 29, 2024
cd69586
feat: added readability and accessibility injections
forgotvas Mar 5, 2024
89ff0df
fix: resize of content and added readability for content types
forgotvas Mar 5, 2024
f6ffabf
fix: readability width calculation
forgotvas Mar 5, 2024
324ef3e
feat: added Discussons paddings
forgotvas Mar 5, 2024
b2a135c
feat: added iPad paddings for Dates tab
forgotvas Mar 5, 2024
ae9110c
feat: added injection to html webview
forgotvas Mar 5, 2024
5542bb6
feat: added readable for profile
forgotvas Mar 5, 2024
a2cacf2
feat: added padding for tab menu
forgotvas Mar 5, 2024
3bf24ac
feat: added paddings to dashboard view
forgotvas Mar 5, 2024
34b59b8
Merge branch 'develop' into feat/ipad-stretch
forgotvas Mar 5, 2024
5c36ce7
fix: merge conflict
forgotvas Mar 5, 2024
2360964
feat: moved filter buttons
forgotvas Mar 5, 2024
f839120
feat: added paddings to Delete Account View
forgotvas Mar 5, 2024
4b010db
feat: added paddings for native discovery view
forgotvas Mar 5, 2024
b74e5e1
feat: added padding for CourseVerticalsView
forgotvas Mar 5, 2024
a4117f4
feat: added paddings for responses view
forgotvas Mar 5, 2024
9ee316f
feat: added paddings to UserProfileView
forgotvas Mar 5, 2024
e06bd3f
fix: do not block scroll from side for UserProfileView
forgotvas Mar 5, 2024
8a1d639
chore: review's changes
forgotvas Mar 6, 2024
827b928
Merge remote-tracking branch 'upstream/develop' into feat/ipad-stretch
forgotvas Mar 11, 2024
60dc883
chore: merge conflicts
forgotvas Mar 11, 2024
83ce735
chore: merge conflict
forgotvas Mar 11, 2024
70f10be
chore: warning
forgotvas Mar 11, 2024
dce9b65
fix: UI bug on iPad when using filters in Discussion #308
forgotvas Mar 12, 2024
8db58a4
Merge remote-tracking branch 'upstream/develop' into feat/ipad-stretch
forgotvas Mar 15, 2024
7b5db6d
fix: merge conflicts
forgotvas Mar 15, 2024
b8c06dc
Merge branch 'feat/ipad-stretch' into fix/discussion-filter
forgotvas Mar 15, 2024
7bb2974
Merge remote-tracking branch 'upstream/develop' into feat/ipad-stretch
forgotvas Mar 19, 2024
0fad965
Merge remote-tracking branch 'upstream/develop' into fix/discussion-f…
forgotvas Mar 19, 2024
7f27c1d
Merge remote-tracking branch 'upstream/develop' into feat/ipad-stretch
forgotvas Mar 20, 2024
82f0d70
chore: merge conflict
forgotvas Mar 20, 2024
b22d620
Merge branch 'feat/ipad-stretch' into fix/discussion-filter
forgotvas Mar 20, 2024
933f366
chore: removed extra horizontal padding
forgotvas Mar 20, 2024
cf62aa0
Revert "chore: removed extra horizontal padding"
forgotvas Mar 20, 2024
fa97432
chore: removed extra horizontal padding
forgotvas Mar 20, 2024
ab28469
Merge branch 'feat/ipad-stretch' into fix/discussion-filter
forgotvas Mar 20, 2024
2f6c115
chore: refactor
forgotvas Mar 20, 2024
e0d5347
chore: label alignment
forgotvas Mar 20, 2024
c68bbd5
Merge remote-tracking branch 'upstream/develop' into feat/ipad-stretch
forgotvas Mar 21, 2024
65fad57
chore: merge conflicts
forgotvas Mar 21, 2024
fc1150a
chore: status bar fix
forgotvas Mar 21, 2024
6092aa6
Merge branch 'feat/ipad-stretch' into fix/discussion-filter
forgotvas Mar 21, 2024
741c643
chore: merge conflict
forgotvas Mar 21, 2024
132ff57
Merge branch 'feat/ipad-stretch' into fix/discussion-filter
forgotvas Mar 21, 2024
4bd37dc
Merge remote-tracking branch 'upstream/develop' into fix/discussion-f…
forgotvas Mar 21, 2024
270c359
chore: set title to be visible
forgotvas Mar 21, 2024
2b13dd1
chore: do not show title on iPad
forgotvas Mar 21, 2024
5253747
chore: removed useless code and fix warnings
forgotvas Mar 21, 2024
3dac173
chore: review's require changes
forgotvas Mar 21, 2024
f9615d6
chore: fixed warnings
forgotvas Mar 22, 2024
d009bab
Merge remote-tracking branch 'upstream/develop' into fix/discussion-f…
forgotvas Mar 25, 2024
59c8952
chore: merge fix
forgotvas Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions Discussion/Discussion/Domain/Model/ThreadType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,36 @@ public enum ThreadType {
case courseTopics(topicID: String)
}

public enum ThreadsFilter {
public enum ThreadsFilter: Identifiable {
public var id: String {
localizedValue
}

case allThreads
case unread
case unanswered

var localizedValue: String {
switch self {
case .allThreads:
return DiscussionLocalization.Posts.Filter.allPosts
case .unread:
return DiscussionLocalization.Posts.Filter.unread
case .unanswered:
return DiscussionLocalization.Posts.Filter.unanswered
}
}
}

public enum SortType {
public enum SortType: Identifiable {
public var id: String {
localizedValue
}

case recentActivity
case mostActivity
case mostVotes

var localizedValue: String {
switch self {
case .recentActivity:
Expand Down
93 changes: 69 additions & 24 deletions Discussion/Discussion/Presentation/Posts/PostsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import Theme
public struct PostsView: View {

@ObservedObject private var viewModel: PostsViewModel
@State private var showingAlert = false
@State private var showFilterSheet = false
@State private var showSortSheet = false
private let router: DiscussionRouter
private let title: String
private let currentBlockID: String
private let courseID: String
private var showTopMenu: Bool
private var isPad: Bool {
UIDevice.current.userInterfaceIdiom == .pad
}

public init(
courseID: String,
Expand Down Expand Up @@ -73,25 +77,10 @@ public struct PostsView: View {
VStack {
HStack {
Group {
Button(action: {
viewModel.generateButtons(type: .filter)
showingAlert = true
}, label: {
CoreAssets.filter.swiftUIImage.renderingMode(.template)
.foregroundColor(Theme.Colors.accentXColor)
Text(viewModel.filterTitle.localizedValue)
})
filterButton
Spacer()
Button(action: {
viewModel.generateButtons(type: .sort)
showingAlert = true
}, label: {
CoreAssets.sort.swiftUIImage.renderingMode(.template)
.foregroundColor(Theme.Colors.accentXColor)
Text(viewModel.sortTitle.localizedValue)
})
}
.foregroundColor(Theme.Colors.accentColor)
sortButton
}.foregroundColor(Theme.Colors.accentColor)
}
.font(Theme.Fonts.labelMedium)
.padding(.horizontal, 24)
Expand Down Expand Up @@ -210,7 +199,6 @@ public struct PostsView: View {
}
}
.accessibilityAction {}
.animation(nil)
.onRightSwipeGesture {
router.back()
}
Expand Down Expand Up @@ -241,13 +229,70 @@ public struct PostsView: View {
Theme.Colors.background
.ignoresSafeArea()
)
// MARK: - Action Sheet
.actionSheet(isPresented: $showingAlert, content: {
ActionSheet(title: Text(DiscussionLocalization.Posts.Alert.makeSelection), buttons: viewModel.filterButtons)
})
}
}

private var filterButton: some View {
Button(
action: {
showFilterSheet = true
},
label: {
CoreAssets.filter.swiftUIImage
.renderingMode(.template)
.foregroundColor(Theme.Colors.accentXColor)
Text(viewModel.filterTitle.localizedValue)
}
)
.confirmationDialog(
DiscussionLocalization.Posts.Alert.makeSelection,
isPresented: $showFilterSheet,
titleVisibility: isPad ? .automatic : .visible,
actions: {
ForEach(viewModel.filterInfos) { info in
Button(
action: {
viewModel.filter(by: info)
},
label: {
Text(info.localizedValue)
}
)
}
}
)
}

private var sortButton: some View {
Button(
action: {
showSortSheet = true
},
label: {
CoreAssets.sort.swiftUIImage.renderingMode(.template)
.foregroundColor(Theme.Colors.accentXColor)
Text(viewModel.sortTitle.localizedValue)
}
)
.confirmationDialog(
DiscussionLocalization.Posts.Alert.makeSelection,
isPresented: $showSortSheet,
titleVisibility: isPad ? .automatic : .visible,
actions: {
ForEach(viewModel.sortInfos) { info in
Button(
action: {
viewModel.sort(by: info)
},
label: {
Text(info.localizedValue)
}
)
}
}
)
}

@MainActor
private func reloadPage(onSuccess: @escaping () -> Void) {
Task {
Expand Down
78 changes: 26 additions & 52 deletions Discussion/Discussion/Presentation/Posts/PostsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ import SwiftUI
import Combine
import Core

public extension ThreadsFilter {

var localizedValue: String {
switch self {
case .allThreads:
return DiscussionLocalization.Posts.Filter.allPosts
case .unread:
return DiscussionLocalization.Posts.Filter.unread
case .unanswered:
return DiscussionLocalization.Posts.Filter.unanswered
}
}
}

public class PostsViewModel: ObservableObject {

public var nextPage = 1
Expand All @@ -40,7 +26,7 @@ public class PostsViewModel: ObservableObject {
@Published var filteredPosts: [DiscussionPost] = []
@Published var filterTitle: ThreadsFilter = .allThreads {
willSet {
if let courseID {
if courseID != nil {
resetPosts()
Task {
_ = await getPosts(pageNumber: 1)
Expand All @@ -50,15 +36,30 @@ public class PostsViewModel: ObservableObject {
}
@Published var sortTitle: SortType = .recentActivity {
willSet {
if let courseID {
if courseID != nil {
resetPosts()
Task {
_ = await getPosts(pageNumber: 1)
}
}
}
}
@Published var filterButtons: [ActionSheet.Button] = []

var filterInfos: [ThreadsFilter] {
[
.allThreads,
.unread,
.unanswered
]
}

var sortInfos: [SortType] {
[
.recentActivity,
.mostActivity,
.mostVotes
]
}

public var courseID: String?
var errorMessage: String? {
Expand Down Expand Up @@ -113,41 +114,14 @@ public class PostsViewModel: ObservableObject {
totalPages = 1
}

public func generateButtons(type: ButtonType) {
switch type {
case .sort:
self.filterButtons = [
ActionSheet.Button.default(Text(DiscussionLocalization.Posts.Sort.recentActivity)) {
self.sortTitle = .recentActivity
self.filteredPosts = self.discussionPosts
},
ActionSheet.Button.default(Text(DiscussionLocalization.Posts.Sort.mostActivity)) {
self.sortTitle = .mostActivity
self.filteredPosts = self.discussionPosts
},
ActionSheet.Button.default(Text(DiscussionLocalization.Posts.Sort.mostVotes)) {
self.sortTitle = .mostVotes
self.filteredPosts = self.discussionPosts
},
.cancel()
]
case .filter:
self.filterButtons = [
ActionSheet.Button.default(Text(DiscussionLocalization.Posts.Filter.allPosts)) {
self.filterTitle = .allThreads
self.filteredPosts = self.discussionPosts
},
ActionSheet.Button.default(Text(DiscussionLocalization.Posts.Filter.unread)) {
self.filterTitle = .unread
self.filteredPosts = self.discussionPosts
},
ActionSheet.Button.default(Text(DiscussionLocalization.Posts.Filter.unanswered)) {
self.filterTitle = .unanswered
self.filteredPosts = self.discussionPosts
},
.cancel()
]
}
public func sort(by value: SortType) {
self.sortTitle = value
self.filteredPosts = self.discussionPosts
}

public func filter(by value: ThreadsFilter) {
self.filterTitle = value
self.filteredPosts = self.discussionPosts
}

func generatePosts(threads: ThreadLists?) -> [DiscussionPost] {
Expand Down
Loading