Compare commits
2 Commits
nprofile-q
...
zap-amount
| Author | SHA1 | Date | |
|---|---|---|---|
|
0b288c921e
|
|||
| f73c0ec1c4 |
@@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
let fallback_zap_amount = 1000
|
let fallback_zap_amount = 21
|
||||||
let default_emoji_reactions = ["🤣", "🤙", "⚡", "💜", "🔥", "😀", "😃", "😄", "🥶"]
|
let default_emoji_reactions = ["🤣", "🤙", "⚡", "💜", "🔥", "😀", "😃", "😄", "🥶"]
|
||||||
|
|
||||||
func setting_property_key(key: String) -> String {
|
func setting_property_key(key: String) -> String {
|
||||||
|
|||||||
@@ -8,6 +8,17 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
|
let zapAmounts: [Int: String] = [
|
||||||
|
69: "😘",
|
||||||
|
420: "🌿",
|
||||||
|
5000: "💜",
|
||||||
|
10_000: "😍",
|
||||||
|
20_000: "🤩",
|
||||||
|
50_000: "🔥",
|
||||||
|
100_000: "🚀",
|
||||||
|
1_000_000: "🤯",
|
||||||
|
]
|
||||||
|
|
||||||
struct ZapAmountItem: Identifiable, Hashable {
|
struct ZapAmountItem: Identifiable, Hashable {
|
||||||
let amount: Int
|
let amount: Int
|
||||||
let icon: String
|
let icon: String
|
||||||
@@ -22,18 +33,13 @@ func get_default_zap_amount_item(_ def: Int) -> ZapAmountItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func get_zap_amount_items(_ default_zap_amt: Int) -> [ZapAmountItem] {
|
func get_zap_amount_items(_ default_zap_amt: Int) -> [ZapAmountItem] {
|
||||||
let def_item = get_default_zap_amount_item(default_zap_amt)
|
var entries = zapAmounts.map { ZapAmountItem(amount: $0.key, icon: $0.value) }
|
||||||
var entries = [
|
|
||||||
ZapAmountItem(amount: 69, icon: "😘"),
|
// Add default zap amount to the list only if it is not one of the preset entries so that it is not duplicated.
|
||||||
ZapAmountItem(amount: 420, icon: "🌿"),
|
if zapAmounts[default_zap_amt] == nil {
|
||||||
ZapAmountItem(amount: 5000, icon: "💜"),
|
let def_item = get_default_zap_amount_item(default_zap_amt)
|
||||||
ZapAmountItem(amount: 10_000, icon: "😍"),
|
entries.append(def_item)
|
||||||
ZapAmountItem(amount: 20_000, icon: "🤩"),
|
}
|
||||||
ZapAmountItem(amount: 50_000, icon: "🔥"),
|
|
||||||
ZapAmountItem(amount: 100_000, icon: "🚀"),
|
|
||||||
ZapAmountItem(amount: 1_000_000, icon: "🤯"),
|
|
||||||
]
|
|
||||||
entries.append(def_item)
|
|
||||||
|
|
||||||
entries.sort { $0.amount < $1.amount }
|
entries.sort { $0.amount < $1.amount }
|
||||||
return entries
|
return entries
|
||||||
|
|||||||
@@ -440,21 +440,15 @@ fileprivate struct QRCameraView<Content: View>: View {
|
|||||||
str.removeFirst("nostr:".count)
|
str.removeFirst("nostr:".count)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let decoded = hex_decode(str),
|
let bech32 = Bech32Object.parse(str)
|
||||||
str.count == 64
|
switch bech32 {
|
||||||
{
|
case .nprofile(let nprofile):
|
||||||
self.pubkey = Pubkey(Data(decoded))
|
self.pubkey = nprofile.author
|
||||||
return
|
case .npub(let pubkey):
|
||||||
|
self.pubkey = pubkey
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if str.starts(with: "npub"),
|
|
||||||
let b32 = try? bech32_decode(str)
|
|
||||||
{
|
|
||||||
self.pubkey = Pubkey(b32.data)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user