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

fix the issues (#57, #67, #68, #69, #70) #66

Merged
merged 6 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ struct CustomListForm : View {
self.searchTextWrapper.searchText = ""
}
}
}.padding(.leading, 16)
}
.padding(.bottom, 10)
}
.frame(height: 200)
.padding(.leading, 16)
.listRowInsets(EdgeInsets())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ struct FanClubHome: ConnectedView {

func map(state: AppState , dispatch: @escaping DispatchFunction) -> Props {
Props(peoples: state.peoplesState.fanClub.map{ $0 }.sorted(),
popular: state.peoplesState.popular.filter{ !state.peoplesState.fanClub.contains($0) },
popular: Array(Set(state.peoplesState.popular))
.filter{ !state.peoplesState.fanClub.contains($0) }
.sorted() { state.peoplesState.peoples[$0]!.name < state.peoplesState.peoples[$1]!.name },
dispatch: dispatch)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct MoviesHomeGridMoviesRow: ConnectedView {
}

func body(props: Props) -> some View {
ScrollView(.horizontal, showsIndicators: false) {
ScrollView(.horizontal, showsIndicators: true) {
LazyHStack(spacing: 16) {
ForEach(props.movies) { movie in
NavigationLink(destination: MovieDetail(movieId: movie.id)) {
Expand All @@ -43,8 +43,9 @@ struct MoviesHomeGridMoviesRow: ConnectedView {
}
}
.frame(height: 150)
.padding(.horizontal, 16)
.padding(.bottom, 10)
}
.padding(.horizontal, 16)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ struct MoviesList: ConnectedView {
let displaySearch: Bool
var pageListener: MoviesPagesListener?

// MARK: - Private var
@State private var selectedItem: String? = nil
@State private var listViewId = UUID()

// MARK: - Computed Props
func map(state: AppState, dispatch: @escaping DispatchFunction) -> Props {
if isSearching {
Expand All @@ -50,7 +54,7 @@ struct MoviesList: ConnectedView {
// MARK: - Computed views
private func moviesRows(props: Props) -> some View {
ForEach(isSearching ? props.searchedMovies ?? [] : movies, id: \.self) { id in
NavigationLink(destination: MovieDetail(movieId: id)) {
NavigationLink(destination: MovieDetail(movieId: id), tag: String(id), selection:$selectedItem) {
MovieRow(movieId: id)
}
}
Expand Down Expand Up @@ -90,7 +94,7 @@ struct MoviesList: ConnectedView {
Text("No results")
} else {
ForEach(props.searcherdPeoples ?? [], id: \.self) { id in
NavigationLink(destination: PeopleDetail(peopleId: id)) {
NavigationLink(destination: PeopleDetail(peopleId: id), tag: String(id), selection:$selectedItem) {
PeopleRow(peopleId: id)
}
}
Expand Down Expand Up @@ -142,8 +146,10 @@ struct MoviesList: ConnectedView {

if isSearching && searchFilter == SearchFilter.peoples.rawValue {
peoplesSection(props: props)
.id(listViewId)
} else {
movieSection(props: props)
.id(listViewId)
}

/// The pagination is done by appending a invisible rectancle at the bottom of the list, and trigerining the next page load as it appear.
Expand All @@ -162,6 +168,13 @@ struct MoviesList: ConnectedView {
}
}
.listStyle(PlainListStyle())
.onAppear {
if selectedItem != nil {
selectedItem = nil
/// Changing view id to refresh view to avoid a bug of SwiftUI List that selected list row remains highlighted
listViewId = UUID()
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct MovieBackdropImage : View {
Image(uiImage: self.imageLoader.image!)
.resizable()
.renderingMode(.original)
.frame(width: 300, height: displayMode == .normal ? 168 : 50)
.frame(width: 280, height: displayMode == .normal ? 168 : 50)
.animation(.easeInOut)
.onAppear{
DispatchQueue.main.async {
Expand All @@ -35,7 +35,7 @@ struct MovieBackdropImage : View {
Rectangle()
.foregroundColor(.gray)
.opacity(0.1)
.frame(width: 300, height: displayMode == .normal ? 168 : 50)
.frame(width: 280, height: displayMode == .normal ? 168 : 50)
}
}
}
Expand Down