From 7454e2af226cfc62f757bcfe26d5ed1f7f82b11a Mon Sep 17 00:00:00 2001 From: sbertix Date: Thu, 7 Jan 2021 17:15:05 +0100 Subject: [PATCH] Update Followers example --- .../Followers.xcodeproj/project.pbxproj | 6 +- .../xcshareddata/xcschemes/Followers.xcscheme | 78 +++++++++++++++++++ .../Followers/Followers/FollowersModel.swift | 8 +- .../Followers/Followers/FollowersView.swift | 4 + 4 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 Examples/Followers/Followers.xcodeproj/xcshareddata/xcschemes/Followers.xcscheme diff --git a/Examples/Followers/Followers.xcodeproj/project.pbxproj b/Examples/Followers/Followers.xcodeproj/project.pbxproj index c92fc581..bd4bc44b 100644 --- a/Examples/Followers/Followers.xcodeproj/project.pbxproj +++ b/Examples/Followers/Followers.xcodeproj/project.pbxproj @@ -341,7 +341,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; DEVELOPMENT_ASSET_PATHS = "\"Followers/Preview Content\""; DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; @@ -363,7 +363,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; DEVELOPMENT_ASSET_PATHS = "\"Followers/Preview Content\""; DEVELOPMENT_TEAM = ""; ENABLE_PREVIEWS = YES; @@ -417,7 +417,7 @@ repositoryURL = "git@github.com:sbertix/Swiftagram.git"; requirement = { kind = upToNextMinorVersion; - minimumVersion = 4.1.0; + minimumVersion = 4.2.0; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/Examples/Followers/Followers.xcodeproj/xcshareddata/xcschemes/Followers.xcscheme b/Examples/Followers/Followers.xcodeproj/xcshareddata/xcschemes/Followers.xcscheme new file mode 100644 index 00000000..8973bf26 --- /dev/null +++ b/Examples/Followers/Followers.xcodeproj/xcshareddata/xcschemes/Followers.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/Followers/Followers/Followers/FollowersModel.swift b/Examples/Followers/Followers/Followers/FollowersModel.swift index e4e61497..e76d00a6 100644 --- a/Examples/Followers/Followers/Followers/FollowersModel.swift +++ b/Examples/Followers/Followers/Followers/FollowersModel.swift @@ -27,7 +27,7 @@ final class FollowersModel: ObservableObject { /// The logged in secret. var secret: Secret? { didSet { - guard let secret = secret, secret.id != oldValue?.id else { return } + guard let secret = secret, secret.identifier != oldValue?.identifier else { return } fetch(secret: secret) } } @@ -42,7 +42,7 @@ final class FollowersModel: ObservableObject { if let secret = KeychainStorage().all().first { self.secret = secret self.current = UserDefaults.standard - .data(forKey: secret.id) + .data(forKey: secret.identifier) .flatMap { try? JSONDecoder().decode(User.self, from: $0) } // Fetch the data. self.fetch(secret: secret) @@ -59,7 +59,7 @@ final class FollowersModel: ObservableObject { /// Fetch values. func fetch(secret: Secret) { // Load info for the logged in user. - Endpoint.User.summary(for: secret.id) + Endpoint.User.summary(for: secret.identifier) .unlocking(with: secret) .publish() .map(\.user) @@ -69,7 +69,7 @@ final class FollowersModel: ObservableObject { // Load the first 3 pages of the current user's followers. // In a real app you might want to fetch all of them. followers = [] - Endpoint.Friendship.following(secret.id) + Endpoint.Friendship.following(secret.identifier) .unlocking(with: secret) .publish() .prefix(3) diff --git a/Examples/Followers/Followers/Followers/FollowersView.swift b/Examples/Followers/Followers/Followers/FollowersView.swift index 1b5b8fa9..b7b76130 100644 --- a/Examples/Followers/Followers/Followers/FollowersView.swift +++ b/Examples/Followers/Followers/Followers/FollowersView.swift @@ -22,8 +22,10 @@ struct FollowersView: View { Text("Loading…") .font(.headline) .foregroundColor(.secondary) + .padding(.vertical) } else if model.followers?.isEmpty == true { Text("No followers.") + .padding(.vertical) } else { ForEach(model.followers ?? [], id: \.username.hashValue) { user in /// Visit **Instagram** on tap. @@ -37,10 +39,12 @@ struct FollowersView: View { Spacer() Image(systemName: "chevron.right").imageScale(.small).foregroundColor(.secondary) } + .padding(.vertical) } } } } + .listStyle(PlainListStyle()) .onAppear { guard self.model.secret == nil else { return } self.shouldDisplayLogin = true