Polish on link card view, sign in flow, status context menu

This commit is contained in:
Thomas Ricouard 2023-01-10 12:57:45 +01:00
parent f50a7f1556
commit 0ae0b7e33f
5 changed files with 66 additions and 21 deletions

View file

@ -665,6 +665,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = IceCubesApp/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Ice Cubes";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
INFOPLIST_KEY_NSCameraUsageDescription = "Upload photos & videos to Mastodon";
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Upload photos & videos to Mastodon";
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
@ -715,6 +716,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = IceCubesApp/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Ice Cubes";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
INFOPLIST_KEY_NSCameraUsageDescription = "Upload photos & videos to Mastodon";
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Upload photos & videos to Mastodon";
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;

View file

@ -8,6 +8,7 @@ import Shimmer
struct AddAccountView: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.scenePhase) private var scenePhase
@EnvironmentObject private var appAccountsManager: AppAccountsManager
@EnvironmentObject private var currentAccount: CurrentAccount
@ -38,19 +39,7 @@ struct AddAccountView: View {
Text(instanceFetchError)
}
if let instance {
Button {
isSigninIn = true
Task {
await signIn()
}
} label: {
if isSigninIn {
ProgressView()
} else {
Text("Sign in")
}
}
.listRowBackground(theme.primaryBackgroundColor)
signInSection
InstanceInfoSection(instance: instance)
} else {
instancesListView
@ -73,12 +62,14 @@ struct AddAccountView: View {
Task {
self.instances = await client.fetchInstances()
}
isSigninIn = false
}
.onChange(of: instanceName) { newValue in
let client = Client(server: newValue)
Task {
do {
self.instance = try await client.get(endpoint: Instances.instance)
self.instanceFetchError = nil
} catch _ as DecodingError {
self.instance = nil
self.instanceFetchError = "This instance is not currently supported."
@ -87,6 +78,14 @@ struct AddAccountView: View {
}
}
}
.onChange(of: scenePhase, perform: { scenePhase in
switch scenePhase {
case .active:
isSigninIn = false
default:
break
}
})
.onOpenURL(perform: { url in
Task {
await continueSignIn(url: url)
@ -95,11 +94,35 @@ struct AddAccountView: View {
}
}
private var signInSection: some View {
Section {
Button {
isSigninIn = true
Task {
await signIn()
}
} label: {
HStack {
Spacer()
if isSigninIn {
ProgressView()
.tint(theme.labelColor)
} else {
Text("Sign in")
.font(.headline)
}
Spacer()
}
}
.buttonStyle(.borderedProminent)
}
.listRowBackground(theme.tintColor)
}
private var instancesListView: some View {
Section("Suggestions") {
if instances.isEmpty {
ProgressView()
.listRowBackground(theme.primaryBackgroundColor)
placeholderRow
} else {
ForEach(instanceName.isEmpty ? instances : instances.filter{ $0.name.contains(instanceName.lowercased()) }) { instance in
Button {
@ -123,6 +146,23 @@ struct AddAccountView: View {
}
}
private var placeholderRow: some View {
VStack(alignment: .leading, spacing: 4) {
Text("Loading...")
.font(.headline)
.foregroundColor(.primary)
Text("Loading, loading, loading ....")
.font(.body)
.foregroundColor(.gray)
Text("Loading ...")
.font(.footnote)
.foregroundColor(.gray)
}
.redacted(reason: .placeholder)
.shimmering()
.listRowBackground(theme.primaryBackgroundColor)
}
private func signIn() async {
do {
signInClient = .init(server: instanceName)

View file

@ -40,12 +40,11 @@ public struct StatusCardView: View {
.font(.body)
.foregroundColor(.gray)
.lineLimit(3)
} else {
Text(card.url.absoluteString)
.font(.body)
.foregroundColor(.gray)
.lineLimit(3)
}
Text(card.url.host() ?? card.url.absoluteString)
.font(.footnote)
.foregroundColor(theme.tintColor)
.lineLimit(1)
}
Spacer()
}.padding(8)

View file

@ -40,6 +40,11 @@ struct StatusRowContextMenu: View {
Label(viewModel.isReblogged ? "Unbookmark" : "Bookmark",
systemImage: "bookmark")
}
Button {
routeurPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
} label: {
Label("Reply", systemImage: "arrowshape.turn.up.left")
}
}
if viewModel.status.visibility == .pub, !viewModel.isRemote {

View file

@ -65,7 +65,6 @@ public struct StatusRowView: View {
viewModel.displaySpoiler = false
}
}
.background(theme.primaryBackgroundColor)
.contextMenu {
StatusRowContextMenu(viewModel: viewModel)
}