Merge branch 'master' into viewModel

This commit is contained in:
Sam DuBois
2022-12-20 09:48:02 -07:00
committed by GitHub
11 changed files with 129 additions and 35 deletions

View File

@@ -17,10 +17,15 @@ struct ImageViewer: View {
VStack{
Text(url.lastPathComponent)
KFImage(url)
KFAnimatedImage(url)
.configure { view in
view.framePreloadCount = 3
}
.cacheOriginalImage()
.loadDiskFileSynchronously()
.scaleFactor(UIScreen.main.scale)
.fade(duration: 0.1)
.aspectRatio(contentMode: .fit)
.tabItem {
Text(url.absoluteString)
}
@@ -41,10 +46,15 @@ struct ImageCarousel: View {
var body: some View {
TabView {
ForEach(urls, id: \.absoluteString) { url in
KFImage(url)
KFAnimatedImage(url)
.configure { view in
view.framePreloadCount = 3
}
.cacheOriginalImage()
.loadDiskFileSynchronously()
.scaleFactor(UIScreen.main.scale)
.fade(duration: 0.1)
.aspectRatio(contentMode: .fit)
.tabItem {
Text(url.absoluteString)
}

View File

@@ -69,7 +69,6 @@ func generate_new_keypair() -> Keypair {
let key = try! secp256k1.Signing.PrivateKey()
let privkey = hex_encode(key.rawRepresentation)
let pubkey = hex_encode(Data(key.publicKey.xonly.bytes))
print("generating privkey:\(privkey) pubkey:\(pubkey)")
return Keypair(pubkey: pubkey, privkey: privkey)
}

View File

@@ -18,6 +18,7 @@ struct AddRelayView: View {
Form {
Section("Add Relay") {
TextField("wss://some.relay.com", text: $relay)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
}
}

View File

@@ -15,8 +15,7 @@ enum NostrPostResult {
let POST_PLACEHOLDER = "Type your post here..."
struct PostView: View {
@State var post: String = POST_PLACEHOLDER
@State var new: Bool = true
@State var post: String = ""
let replying_to: NostrEvent?
@FocusState var focus: Bool
@@ -50,7 +49,7 @@ struct PostView: View {
}
var is_post_empty: Bool {
return post == POST_PLACEHOLDER || post.allSatisfy { $0.isWhitespace }
return post.allSatisfy { $0.isWhitespace }
}
var body: some View {
@@ -71,18 +70,17 @@ struct PostView: View {
}
.padding([.top, .bottom], 4)
TextEditor(text: $post)
.foregroundColor(self.post == POST_PLACEHOLDER ? .gray : .primary)
.focused($focus)
.textInputAutocapitalization(.sentences)
.onTapGesture {
handle_post_placeholder()
ZStack(alignment: .topLeading) {
TextEditor(text: $post)
.focused($focus)
.textInputAutocapitalization(.sentences)
if post.isEmpty {
Text(POST_PLACEHOLDER)
.padding(.top, 8)
.padding(.leading, 10)
.foregroundColor(Color(uiColor: .placeholderText))
}
.onChange(of: post) { value in
handle_post_placeholder()
}
}
}
.onAppear() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
@@ -91,14 +89,5 @@ struct PostView: View {
}
.padding()
}
func handle_post_placeholder() {
guard new else {
return
}
new = false
post = post.replacingOccurrences(of: POST_PLACEHOLDER, with: "")
}
}

View File

@@ -56,16 +56,19 @@ struct ProfilePicView: View {
Group {
let pic = picture ?? profiles.lookup(id: pubkey)?.picture ?? robohash(pubkey)
let url = URL(string: pic)
let processor = ResizingImageProcessor(referenceSize: CGSize(width: size, height: size))
KFImage.url(url)
KFAnimatedImage(url)
.configure { view in
view.framePreloadCount = 1
}
.placeholder { _ in
Placeholder
}
.setProcessor(processor)
.cacheOriginalImage()
.scaleFactor(UIScreen.main.scale)
.loadDiskFileSynchronously()
.fade(duration: 0.1)
.frame(width: size, height: size)
.clipShape(Circle())
.overlay(Circle().stroke(highlight_color(highlight), lineWidth: pfp_line_width(highlight)))
}

View File

@@ -88,6 +88,7 @@ struct ProfileView: View {
@StateObject var followers: FollowersModel
@Environment(\.dismiss) var dismiss
@Environment(\.colorScheme) var colorScheme
//@EnvironmentObject var profile: ProfileModel

View File

@@ -19,6 +19,7 @@ struct SearchHomeView: View {
TextField("", text: $search)
.padding(8)
.padding(.leading, 35)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
Label("", systemImage: "xmark.square")
.padding(EdgeInsets(top: 0.0, leading: 0.0, bottom: 0.0, trailing: 10.0))