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

[DRAFT] iOS 15+ support #71

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions MovieSwift/MovieSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@
DEVELOPMENT_TEAM = Z6P74P6T99;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = MovieSwift/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -1272,7 +1272,7 @@
DEVELOPMENT_TEAM = Z6P74P6T99;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = MovieSwift/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct CustomListDetail : View {
.sheet(isPresented: $isEditingFormPresented,
content: { CustomListForm(editingListId: self.listId).environmentObject(self.store)
})
.listStyle(.plain)
.environment(\.editMode, .constant(isSearching ? .active : .inactive))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct CustomListForm : View {
coverSection
buttonsSection
}
.listStyle(.plain)
.navigationBarTitle(Text("New list"))
}
.navigationViewStyle(StackNavigationViewStyle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct FanClubHome: ConnectedView {
}

@State private var currentPage = 1
@State private var searchText = ""

func map(state: AppState , dispatch: @escaping DispatchFunction) -> Props {
Props(peoples: state.peoplesState.fanClub.map{ $0 }.sorted(),
Expand Down Expand Up @@ -56,9 +57,11 @@ struct FanClubHome: ConnectedView {
}
}
}
.listStyle(.insetGrouped)
.navigationBarTitle("Fan Club")
.animation(.spring())
}
.searchable(text: $searchText)
.onAppear {
if self.currentPage == 1{
props.dispatch(PeopleActions.FetchPopular(page: self.currentPage))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct MovieDetail: ConnectedView {
if props.similar?.isEmpty == false {
MovieCrosslineRow(title: "Similar Movies", movies: props.similar ?? [])
}
if props.recommended?.isEmpty == false {
if props.recommended?.isEmpty == false {
MovieCrosslineRow(title: "Recommended Movies", movies: props.recommended ?? [])
}
if props.movie.images?.posters?.isEmpty == false {
Expand All @@ -182,6 +182,7 @@ struct MovieDetail: ConnectedView {
topSection(props: props)
bottomSection(props: props)
}
.listStyle(.plain)
.navigationBarTitle(Text(props.movie.userTitle), displayMode: .large)
.navigationBarItems(trailing: Button(action: onAddButton) {
Image(systemName: "text.badge.plus").imageScale(.large)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ struct MovieCoverRow : ConnectedView {
fill: false)
VStack(alignment: .leading) {
HStack(spacing: 16) {
MoviePosterImage(imageLoader: ImageLoaderCache.shared.loaderFor(path: props.movie.poster_path,
size: .medium),
MoviePosterImage(posterURL: ImageService.Size.medium.path(poster: props.movie.poster_path ?? ""),
posterSize: .medium)
.padding(.leading, 16)
VStack(alignment: .leading, spacing: 16) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ struct MovieDetailRowItem: View {
NavigationLink(destination: MovieDetail(movieId: movie.id)) {
VStack(alignment: .center) {
ZStack(alignment: .topLeading) {
MoviePosterImage(imageLoader: ImageLoaderCache.shared.loaderFor(path: movie.poster_path,
size: .medium),
MoviePosterImage(posterURL: ImageService.Size.medium.path(poster: movie.poster_path ?? ""),
posterSize: .medium)
ListImage(movieId: movie.id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ struct MoviePostersRow : View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 32) {
ForEach(self.posters) { poster in
MoviePosterImage(imageLoader: ImageLoaderCache.shared.loaderFor(path: poster.file_path,
size: .medium),
MoviePosterImage(posterURL: ImageService.Size.medium.path(poster: poster.file_path),
posterSize: .medium)
.onTapGesture {
withAnimation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ struct MovieGridRow: ConnectedView {


func body(props: Props) -> some View {
MoviePosterImage(imageLoader: ImageLoaderCache.shared.loaderFor(path: props.movie.poster_path,
size: .medium),
MoviePosterImage(posterURL: ImageService.Size.medium.path(poster: props.movie.poster_path ?? ""),
posterSize: .medium)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ struct MoviesHomeGridMoviesRow: ConnectedView {
ForEach(props.movies) { movie in
NavigationLink(destination: MovieDetail(movieId: movie.id)) {
ZStack {
MoviePosterImage(imageLoader: ImageLoaderCache.shared.loaderFor(path: movie.poster_path,
size: .medium),
MoviePosterImage(posterURL: ImageService.Size.medium.path(poster: movie.poster_path ?? ""),
posterSize: .medium)
.contextMenu{ MovieContextMenu(movieId: movie.id) }
ListImage(movieId: movie.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct MoviesList: ConnectedView {
}
}
}
.listStyle(PlainListStyle())
.listStyle(.plain)
.onAppear {
if selectedItem != nil {
selectedItem = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ struct MovieRow: ConnectedView {
func body(props: Props) -> some View {
HStack {
ZStack(alignment: .topLeading) {
MoviePosterImage(imageLoader: ImageLoaderCache.shared.loaderFor(path: props.movie.poster_path,
size: .medium),
MoviePosterImage(posterURL: ImageService.Size.medium.path(poster: props.movie.poster_path ?? ""),
posterSize: .medium)
if displayListImage {
ListImage(movieId: movieId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ struct PeopleDetailMovieRow : View {
var body: some View {
HStack {
ZStack {
MoviePosterImage(imageLoader: ImageLoaderCache.shared.loaderFor(path: movie.poster_path,
size: .small),
MoviePosterImage(posterURL: ImageService.Size.small.path(poster: movie.poster_path ?? ""),
posterSize: .small)
ListImage(movieId: movieId)
}.fixedSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ImageService {
case cast = "https://image.tmdb.org/t/p/w185/"
case original = "https://image.tmdb.org/t/p/original/"

func path(poster: String) -> URL {
public func path(poster: String) -> URL {
return URL(string: rawValue)!.appendingPathComponent(poster)
}
}
Expand Down
19 changes: 5 additions & 14 deletions MovieSwift/Shared/views/MoviePosterImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,16 @@ import SwiftUI
import Backend

struct MoviePosterImage: View {
@ObservedObject var imageLoader: ImageLoader
@State var isImageLoaded = false
let posterURL: URL?
let posterSize: PosterStyle.Size

var body: some View {
if let image = imageLoader.image {
Image(uiImage: image)
.resizable()
.renderingMode(.original)
.posterStyle(loaded: true, size: posterSize)
.onAppear{
isImageLoaded = true
}
.animation(.easeInOut)
.transition(.opacity)
} else {
AsyncImage(url: posterURL) {
$0.resizable()
} placeholder: {
Rectangle()
.foregroundColor(.gray)
.posterStyle(loaded: false, size: posterSize)
}
.posterStyle(loaded: true, size: posterSize)
}
}