Privacy view with image cache

This commit is contained in:
Lumaa 2024-03-07 23:24:44 +01:00
parent 7c26ee7e74
commit 3a8176f931
6 changed files with 128 additions and 4 deletions

View File

@ -47,6 +47,7 @@
B999DE5E2B76F9D100509868 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = B999DE5D2B76F9D100509868 /* Message.swift */; }; B999DE5E2B76F9D100509868 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = B999DE5D2B76F9D100509868 /* Message.swift */; };
B999DE602B76FB3E00509868 /* ContactRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = B999DE5F2B76FB3E00509868 /* ContactRow.swift */; }; B999DE602B76FB3E00509868 /* ContactRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = B999DE5F2B76FB3E00509868 /* ContactRow.swift */; };
B9B469B02B9A275F00AD5585 /* FollowGoalWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B469AF2B9A275F00AD5585 /* FollowGoalWidget.swift */; }; B9B469B02B9A275F00AD5585 /* FollowGoalWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B469AF2B9A275F00AD5585 /* FollowGoalWidget.swift */; };
B9B469B22B9A6E8300AD5585 /* PrivacyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B469B12B9A6E8300AD5585 /* PrivacyView.swift */; };
B9B63B212B442D1500BBC82D /* DynamicTextEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B63B202B442D1500BBC82D /* DynamicTextEditor.swift */; }; B9B63B212B442D1500BBC82D /* DynamicTextEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B63B202B442D1500BBC82D /* DynamicTextEditor.swift */; };
B9B63B232B447B8000BBC82D /* PostCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B63B222B447B8000BBC82D /* PostCardView.swift */; }; B9B63B232B447B8000BBC82D /* PostCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B63B222B447B8000BBC82D /* PostCardView.swift */; };
B9B63B252B44997400BBC82D /* QuotePostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B63B242B44997400BBC82D /* QuotePostView.swift */; }; B9B63B252B44997400BBC82D /* QuotePostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9B63B242B44997400BBC82D /* QuotePostView.swift */; };
@ -183,6 +184,7 @@
B999DE5D2B76F9D100509868 /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; }; B999DE5D2B76F9D100509868 /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
B999DE5F2B76FB3E00509868 /* ContactRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactRow.swift; sourceTree = "<group>"; }; B999DE5F2B76FB3E00509868 /* ContactRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactRow.swift; sourceTree = "<group>"; };
B9B469AF2B9A275F00AD5585 /* FollowGoalWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowGoalWidget.swift; sourceTree = "<group>"; }; B9B469AF2B9A275F00AD5585 /* FollowGoalWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowGoalWidget.swift; sourceTree = "<group>"; };
B9B469B12B9A6E8300AD5585 /* PrivacyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyView.swift; sourceTree = "<group>"; };
B9B63B202B442D1500BBC82D /* DynamicTextEditor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicTextEditor.swift; sourceTree = "<group>"; }; B9B63B202B442D1500BBC82D /* DynamicTextEditor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicTextEditor.swift; sourceTree = "<group>"; };
B9B63B222B447B8000BBC82D /* PostCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCardView.swift; sourceTree = "<group>"; }; B9B63B222B447B8000BBC82D /* PostCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCardView.swift; sourceTree = "<group>"; };
B9B63B242B44997400BBC82D /* QuotePostView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuotePostView.swift; sourceTree = "<group>"; }; B9B63B242B44997400BBC82D /* QuotePostView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuotePostView.swift; sourceTree = "<group>"; };
@ -482,6 +484,7 @@
B9CC45B72B40A2D6001E4FA5 /* AboutView.swift */, B9CC45B72B40A2D6001E4FA5 /* AboutView.swift */,
B98BC7482B46CEDA00595441 /* AppearenceView.swift */, B98BC7482B46CEDA00595441 /* AppearenceView.swift */,
B97798882B853E6600DC869F /* UpdateView.swift */, B97798882B853E6600DC869F /* UpdateView.swift */,
B9B469B12B9A6E8300AD5585 /* PrivacyView.swift */,
); );
path = Settings; path = Settings;
sourceTree = "<group>"; sourceTree = "<group>";
@ -700,6 +703,7 @@
B98BC7472B46CE6300595441 /* PostDetailsView.swift in Sources */, B98BC7472B46CE6300595441 /* PostDetailsView.swift in Sources */,
B9CC45B82B40A2D6001E4FA5 /* AboutView.swift in Sources */, B9CC45B82B40A2D6001E4FA5 /* AboutView.swift in Sources */,
B98F47962B645DF40092000F /* EmojiSelector.swift in Sources */, B98F47962B645DF40092000F /* EmojiSelector.swift in Sources */,
B9B469B22B9A6E8300AD5585 /* PrivacyView.swift in Sources */,
B9FB94882B2E223E00D81C07 /* Emoji.swift in Sources */, B9FB94882B2E223E00D81C07 /* Emoji.swift in Sources */,
B93B67782B42E8F0000892E9 /* TextEmoji.swift in Sources */, B93B67782B42E8F0000892E9 /* TextEmoji.swift in Sources */,
B9FB94762B2E023D00D81C07 /* TabsView.swift in Sources */, B9FB94762B2E023D00D81C07 /* TabsView.swift in Sources */,

View File

@ -4,6 +4,7 @@ import SwiftUI
struct LargeButton: ButtonStyle { struct LargeButton: ButtonStyle {
var filled: Bool = false var filled: Bool = false
var filledColor: Color = Color(uiColor: UIColor.label)
var height: CGFloat? = nil var height: CGFloat? = nil
var disabled: Bool = false var disabled: Bool = false
@ -11,7 +12,7 @@ struct LargeButton: ButtonStyle {
if disabled { if disabled {
Color.gray Color.gray
} else { } else {
Color(uiColor: UIColor.label) filledColor
} }
} }

View File

@ -125,9 +125,11 @@ public enum RouterDestination: Hashable {
case settings case settings
case support case support
case appearence case appearence
case about
case privacy
case account(acc: Account) case account(acc: Account)
case post(status: Status) case post(status: Status)
case about
case contacts case contacts
case timeline(timeline: TimelineFilter?) case timeline(timeline: TimelineFilter?)
} }
@ -154,6 +156,8 @@ extension View {
AboutView() AboutView()
case .contacts: case .contacts:
ContactsView() ContactsView()
case .privacy:
PrivacyView()
case .timeline(let timeline): case .timeline(let timeline):
PostsView(filter: timeline ?? .home, showHero: false) PostsView(filter: timeline ?? .home, showHero: false)
} }

View File

@ -1239,6 +1239,22 @@
} }
} }
}, },
"privacy" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Privacy"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Confidentialité"
}
}
}
},
"setting.appearence" : { "setting.appearence" : {
"localizations" : { "localizations" : {
"en" : { "en" : {
@ -1575,6 +1591,54 @@
} }
} }
}, },
"settings.privacy.clear" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Clear"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Vider"
}
}
}
},
"settings.privacy.clear-cache" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Image cache"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cache des images"
}
}
}
},
"settings.privacy.cleared" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cleared!"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Vidé !"
}
}
}
},
"shop.best" : { "shop.best" : {
"localizations" : { "localizations" : {
"en" : { "en" : {
@ -2916,4 +2980,4 @@
} }
}, },
"version" : "1.0" "version" : "1.0"
} }

View File

@ -0,0 +1,40 @@
//Made by Lumaa
import SwiftUI
import Nuke
struct PrivacyView: View {
@EnvironmentObject private var navigator: Navigator
@State private var clearedCache: Bool = false
var body: some View {
List {
//TODO: Visibilty, Blocklist & Mutelist
HStack {
Text("settings.privacy.clear-cache")
Spacer()
Button {
let cache = ImagePipeline.shared.cache
cache.removeAll()
withAnimation(.spring) {
clearedCache = true
}
} label: {
Text(clearedCache ? "settings.privacy.cleared" : "settings.privacy.clear")
}
.buttonStyle(LargeButton(filled: true, filledColor: clearedCache ? Color.green : Color(uiColor: UIColor.label), height: 7.5))
.disabled(clearedCache)
}
.listRowThreaded()
}
.listThreaded()
}
}
#Preview {
PrivacyView()
}

View File

@ -69,6 +69,13 @@ struct SettingsView: View {
} }
.listRowThreaded() .listRowThreaded()
Button {
navigator.navigate(to: .privacy)
} label: {
Label("privacy", systemImage: "lock")
}
.listRowThreaded()
Button { Button {
navigator.presentedCover = .shop navigator.presentedCover = .shop
} label: { } label: {
@ -125,7 +132,11 @@ extension SettingsView {
@State private var error: Bool = false @State private var error: Bool = false
private var currentAccount: Bool { private var currentAccount: Bool {
return AccountManager.shared.forceAccount().acct == app.accountName ?? "" let currentAccount = AccountManager.shared.forceAccount()
let currentClient = AccountManager.shared.forceClient()
let currentAcct = "\(currentAccount.acct)@\(currentClient.server)"
return currentAcct == app.accountName ?? ""
} }
init(app: AppAccount) { init(app: AppAccount) {