mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 02:01:02 +00:00
Fix warnings + better recently used tags
This commit is contained in:
parent
bb55154b75
commit
8c8c551686
11 changed files with 41 additions and 25 deletions
|
@ -15,7 +15,14 @@ struct RecenTagsSettingView: View {
|
|||
var body: some View {
|
||||
Form {
|
||||
ForEach(tags) { tag in
|
||||
Text("#\(tag.title)")
|
||||
VStack(alignment: .leading) {
|
||||
Text("#\(tag.title)")
|
||||
.font(.scaledBody)
|
||||
.foregroundColor(.primary)
|
||||
Text(tag.formattedDate)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}.onDelete { indexes in
|
||||
if let index = indexes.first {
|
||||
context.delete(tags[index])
|
||||
|
|
|
@ -61,12 +61,12 @@ public enum AccountsListMode {
|
|||
let link: LinkHandler?
|
||||
switch mode {
|
||||
case let .followers(accountId):
|
||||
var account: Account = try await client.get(endpoint: Accounts.accounts(id: accountId))
|
||||
let account: Account = try await client.get(endpoint: Accounts.accounts(id: accountId))
|
||||
totalCount = account.followersCount
|
||||
(accounts, link) = try await client.getWithLink(endpoint: Accounts.followers(id: accountId,
|
||||
maxId: nil))
|
||||
case let .following(accountId):
|
||||
var account: Account = try await client.get(endpoint: Accounts.accounts(id: accountId))
|
||||
let account: Account = try await client.get(endpoint: Accounts.accounts(id: accountId))
|
||||
totalCount = account.followingCount
|
||||
(accounts, link) = try await client.getWithLink(endpoint: Accounts.following(id: accountId,
|
||||
maxId: nil))
|
||||
|
|
|
@ -52,9 +52,9 @@ import Status
|
|||
Task {
|
||||
if let data = await getItemImageData(item: item) {
|
||||
if isChangingAvatar {
|
||||
await uploadAvatar(data: data)
|
||||
_ = await uploadAvatar(data: data)
|
||||
} else if isChangingHeader {
|
||||
await uploadHeader(data: data)
|
||||
_ = await uploadHeader(data: data)
|
||||
}
|
||||
await fetchAccount()
|
||||
isChangingAvatar = false
|
||||
|
|
|
@ -122,7 +122,7 @@ struct AccountPopoverView: View {
|
|||
}
|
||||
|
||||
private var adaptiveConfig: AvatarView.FrameConfig {
|
||||
var cornerRadius: CGFloat = if config == .badge || theme.avatarShape == .circle {
|
||||
let cornerRadius: CGFloat = if config == .badge || theme.avatarShape == .circle {
|
||||
config.width / 2
|
||||
} else {
|
||||
config.cornerRadius
|
||||
|
|
|
@ -21,7 +21,7 @@ public struct AvatarView: View {
|
|||
}
|
||||
|
||||
private var adaptiveConfig: FrameConfig {
|
||||
var cornerRadius: CGFloat = if config == .badge || theme.avatarShape == .circle {
|
||||
let cornerRadius: CGFloat = if config == .badge || theme.avatarShape == .circle {
|
||||
config.width / 2
|
||||
} else {
|
||||
config.cornerRadius
|
||||
|
|
|
@ -5,8 +5,8 @@ import UIKit
|
|||
struct MediaUIImageTransferable: Codable, Transferable {
|
||||
let url: URL
|
||||
|
||||
func fetchAsImage() async -> Image {
|
||||
let data = try? await URLSession.shared.data(from: url).0
|
||||
func fetchAsImage() -> Image {
|
||||
let data = try? Data(contentsOf: url)
|
||||
guard let data, let uiimage = UIImage(data: data) else {
|
||||
return Image(systemName: "photo")
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ struct MediaUIImageTransferable: Codable, Transferable {
|
|||
|
||||
static var transferRepresentation: some TransferRepresentation {
|
||||
ProxyRepresentation { media in
|
||||
await media.fetchAsImage()
|
||||
media.fetchAsImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,3 +11,9 @@ import SwiftUI
|
|||
self.lastUse = Date()
|
||||
}
|
||||
}
|
||||
|
||||
extension RecentTag {
|
||||
public var formattedDate: String {
|
||||
DateFormatterCache.shared.createdAtRelativeFormatter.localizedString(for: lastUse, relativeTo: Date())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,15 @@ extension StatusEditorAutoCompleteView {
|
|||
viewModel.selectHashtagSuggestion(tag: tag.title)
|
||||
}
|
||||
} label: {
|
||||
Text("#\(tag.title)")
|
||||
.font(.scaledFootnote)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(theme.labelColor)
|
||||
VStack(alignment: .leading) {
|
||||
Text("#\(tag.title)")
|
||||
.font(.scaledFootnote)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(theme.labelColor)
|
||||
Text(tag.formattedDate)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundStyle(theme.tintColor)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ extension StatusEditorAutoCompleteView {
|
|||
.font(.scaledFootnote)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(theme.labelColor)
|
||||
Text(tag.formattedDate)
|
||||
.font(.scaledFootnote)
|
||||
.foregroundStyle(theme.tintColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,11 @@ struct StatusEditorAutoCompleteView: View {
|
|||
if !viewModel.mentionsSuggestions.isEmpty {
|
||||
Self.MentionsView(viewModel: viewModel)
|
||||
} else {
|
||||
suggestionsTagView
|
||||
if viewModel.showRecentsTagsInline {
|
||||
Self.RecentTagsView(viewModel: viewModel, isTagSuggestionExpanded: $isTagSuggestionExpanded)
|
||||
} else {
|
||||
Self.RemoteTagsView(viewModel: viewModel, isTagSuggestionExpanded: $isTagSuggestionExpanded)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
|
@ -54,13 +58,4 @@ struct StatusEditorAutoCompleteView: View {
|
|||
.background(.thinMaterial)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var suggestionsTagView: some View {
|
||||
if viewModel.showRecentsTagsInline {
|
||||
Self.RecentTagsView(viewModel: viewModel, isTagSuggestionExpanded: $isTagSuggestionExpanded)
|
||||
} else {
|
||||
Self.RemoteTagsView(viewModel: viewModel, isTagSuggestionExpanded: $isTagSuggestionExpanded)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public actor TimelineCache {
|
|||
}
|
||||
|
||||
func setLatestSeenStatuses(_ statuses: [Status], for client: Client, filter: String) {
|
||||
var statuses = statuses.sorted(by: { $0.createdAt.asDate > $1.createdAt.asDate })
|
||||
let statuses = statuses.sorted(by: { $0.createdAt.asDate > $1.createdAt.asDate })
|
||||
if filter == "Home" {
|
||||
UserDefaults.standard.set(statuses.map{ $0.id }, forKey: "timeline-last-seen-\(client.id)")
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue