21
damus/Assets.xcassets/bitcoin-p2p.imageset/Contents.json
vendored
Normal file
21
damus/Assets.xcassets/bitcoin-p2p.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "bitcoin-p2p.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
damus/Assets.xcassets/bitcoin-p2p.imageset/bitcoin-p2p.png
vendored
Normal file
BIN
damus/Assets.xcassets/bitcoin-p2p.imageset/bitcoin-p2p.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 187 KiB |
21
damus/Assets.xcassets/digital-nomad.imageset/Contents.json
vendored
Normal file
21
damus/Assets.xcassets/digital-nomad.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "digital-nomad.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
damus/Assets.xcassets/digital-nomad.imageset/digital-nomad.png
vendored
Normal file
BIN
damus/Assets.xcassets/digital-nomad.imageset/digital-nomad.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
21
damus/Assets.xcassets/encrypted-message.imageset/Contents.json
vendored
Normal file
21
damus/Assets.xcassets/encrypted-message.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "encrypted-message.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
damus/Assets.xcassets/encrypted-message.imageset/encrypted-message.png
vendored
Normal file
BIN
damus/Assets.xcassets/encrypted-message.imageset/encrypted-message.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
21
damus/Assets.xcassets/logo-nobg.imageset/Contents.json
vendored
Normal file
21
damus/Assets.xcassets/logo-nobg.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "damus-nobg.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
damus/Assets.xcassets/logo-nobg.imageset/damus-nobg.png
vendored
Normal file
BIN
damus/Assets.xcassets/logo-nobg.imageset/damus-nobg.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 176 KiB |
21
damus/Assets.xcassets/undercover.imageset/Contents.json
vendored
Normal file
21
damus/Assets.xcassets/undercover.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "undercover.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
damus/Assets.xcassets/undercover.imageset/undercover.png
vendored
Normal file
BIN
damus/Assets.xcassets/undercover.imageset/undercover.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
@@ -30,16 +30,6 @@ enum ThreadState {
|
||||
case chatroom
|
||||
}
|
||||
|
||||
enum Timeline: String, CustomStringConvertible {
|
||||
case home
|
||||
case notifications
|
||||
case global
|
||||
|
||||
var description: String {
|
||||
return self.rawValue
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@State var status: String = "Not connected"
|
||||
@State var active_sheet: Sheets? = nil
|
||||
@@ -108,11 +98,11 @@ struct ContentView: View {
|
||||
EmptyView()
|
||||
}
|
||||
switch selected_timeline {
|
||||
case .search:
|
||||
SearchHomeView()
|
||||
|
||||
case .home:
|
||||
PostingTimelineView
|
||||
.onAppear() {
|
||||
//switch_timeline(.home)
|
||||
}
|
||||
|
||||
case .notifications:
|
||||
TimelineView(events: $notifications, damus: damus)
|
||||
@@ -718,3 +708,28 @@ func update_filters_with_since(last_of_kind: [Int: NostrEvent], filters: [NostrF
|
||||
}
|
||||
}
|
||||
|
||||
struct Keypair {
|
||||
let pubkey: String
|
||||
let privkey: String
|
||||
}
|
||||
|
||||
func save_keypair(pubkey: String, privkey: String) {
|
||||
UserDefaults.standard.set(pubkey, forKey: "pubkey")
|
||||
UserDefaults.standard.set(privkey, forKey: "privkey")
|
||||
}
|
||||
|
||||
func get_saved_keypair() -> Keypair? {
|
||||
get_saved_pubkey().flatMap { pubkey in
|
||||
get_saved_privkey().map { privkey in
|
||||
return Keypair(pubkey: pubkey, privkey: privkey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func get_saved_pubkey() -> String? {
|
||||
return UserDefaults.standard.string(forKey: "pubkey")
|
||||
}
|
||||
|
||||
func get_saved_privkey() -> String? {
|
||||
return UserDefaults.standard.string(forKey: "privkey")
|
||||
}
|
||||
|
||||
@@ -121,6 +121,12 @@ extension Notification.Name {
|
||||
}
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
static var login: Notification.Name {
|
||||
return Notification.Name("login")
|
||||
}
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
static var followed: Notification.Name {
|
||||
return Notification.Name("followed")
|
||||
@@ -7,6 +7,18 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum Timeline: String, CustomStringConvertible {
|
||||
case home
|
||||
case notifications
|
||||
case global
|
||||
case search
|
||||
|
||||
var description: String {
|
||||
return self.rawValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct MainTabView: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
@@ -72,6 +84,7 @@ struct TabBar: View {
|
||||
Divider()
|
||||
HStack {
|
||||
TabButton(timeline: .home, img: "house", selected: $selected, action: action)
|
||||
TabButton(timeline: .search, img: "magnifyingglass.circle", selected: $selected, action: action)
|
||||
NotificationsTab(new_notifications: $new_notifications, selected: $selected, action: action)
|
||||
TabButton(timeline: .global, img: "globe.americas", selected: $selected, action: action)
|
||||
}
|
||||
|
||||
20
damus/Views/SearchHomeView.swift
Normal file
20
damus/Views/SearchHomeView.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SearchHomeView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2022-05-19.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SearchHomeView: View {
|
||||
var body: some View {
|
||||
Text("Search Home")
|
||||
}
|
||||
}
|
||||
|
||||
struct SearchHomeView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SearchHomeView()
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,122 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
func hex_col(r: UInt8, g: UInt8, b: UInt8) -> Color {
|
||||
return Color(.sRGB,
|
||||
red: Double(r) / Double(0xff),
|
||||
green: Double(g) / Double(0xff),
|
||||
blue: Double(b) / Double(0xff),
|
||||
opacity: 1.0)
|
||||
}
|
||||
|
||||
let damus_grad_c1 = hex_col(r: 0x1c, g: 0x55, b: 0xff)
|
||||
let damus_grad_c2 = hex_col(r: 0x7f, g: 0x35, b: 0xab)
|
||||
let damus_grad_c3 = hex_col(r: 0xff, g: 0x0b, b: 0xd6)
|
||||
let damus_grad = [damus_grad_c1, damus_grad_c2, damus_grad_c3]
|
||||
|
||||
struct SetupView: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
ZStack {
|
||||
LinearGradient(colors: damus_grad, startPoint: .bottomLeading, endPoint: .topTrailing)
|
||||
.edgesIgnoringSafeArea([.top,.bottom])
|
||||
|
||||
VStack(alignment: .center) {
|
||||
Image("logo-nobg")
|
||||
.resizable()
|
||||
.frame(width: 128.0, height: 128.0, alignment: .center)
|
||||
.padding([.top], 20.0)
|
||||
Text("Damus")
|
||||
.font(Font.custom("Nunito", size: 50.0))
|
||||
.kerning(-2)
|
||||
.foregroundColor(.white)
|
||||
|
||||
CarouselView()
|
||||
|
||||
Spacer()
|
||||
|
||||
Button("Create Account") {
|
||||
print("Create Account")
|
||||
}
|
||||
.font(.body.bold())
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 300, height: 50)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 4.0)
|
||||
.stroke(Color.white, lineWidth: 2.0)
|
||||
.background(Color.white.opacity(0.15))
|
||||
)
|
||||
|
||||
Button("Login") {
|
||||
notify(.login, ())
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
.padding([.top], 20)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CarouselText(_ txt: String) -> some View {
|
||||
return Text(txt)
|
||||
}
|
||||
|
||||
struct CarouselItem: Identifiable {
|
||||
let image: Image
|
||||
let text: Text
|
||||
|
||||
let id = UUID().uuidString
|
||||
}
|
||||
|
||||
struct CarouselItemView: View {
|
||||
let item: CarouselItem
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 30) {
|
||||
item.image
|
||||
.resizable()
|
||||
.frame(width: 120, height: 120)
|
||||
item.text
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.title2)
|
||||
.foregroundColor(Color.white)
|
||||
.padding([.leading,.trailing], 50.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let carousel_items = [
|
||||
CarouselItem(image: Image("digital-nomad"), text: Text("Welcome to the social network \(Text("you").italic()) control.")),
|
||||
CarouselItem(image: Image("encrypted-message"),
|
||||
text: Text("\(Text("Encrypted").bold()). End-to-End encrypted private messaging. Keep Big Tech out of your DMs")),
|
||||
CarouselItem(image: Image("undercover"),
|
||||
text: Text("\(Text("Private").bold()). Creating an account doesn't require a phone number, email or name. Get started right away with zero friction.")),
|
||||
CarouselItem(image: Image("bitcoin-p2p"),
|
||||
text: Text("\(Text("Earn Money").bold()). Tip your friend's posts and stack sats with Bitcoin⚡️, the native currency of the internet."))
|
||||
]
|
||||
|
||||
struct CarouselView: View {
|
||||
var body: some View {
|
||||
TabView {
|
||||
ForEach(carousel_items) { item in
|
||||
CarouselItemView(item: item)
|
||||
.tabItem {
|
||||
Text(item.image)
|
||||
}
|
||||
}
|
||||
}
|
||||
.tabViewStyle(PageTabViewStyle())
|
||||
}
|
||||
}
|
||||
|
||||
struct SetupView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SetupView()
|
||||
Group {
|
||||
SetupView()
|
||||
.previewDevice(PreviewDevice(rawValue: "iPhone SE (3rd generation)"))
|
||||
SetupView()
|
||||
.previewDevice(PreviewDevice(rawValue: "iPhone 13 Pro Max"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,31 @@ import SwiftUI
|
||||
struct damusApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
MainView()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct MainView: View {
|
||||
@State var needs_setup = true;
|
||||
|
||||
var body: some View {
|
||||
if needs_setup {
|
||||
SetupView()
|
||||
.onReceive(handle_notify(.login)) { notif in
|
||||
needs_setup = false
|
||||
}
|
||||
} else {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func needs_setup() -> Bool {
|
||||
let _ = get_saved_privkey()
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user