Files
damus/damus/Views/SetupView.swift
2023-05-29 14:38:24 -07:00

122 lines
3.8 KiB
Swift

//
// SetupView.swift
// damus
//
// Created by William Casarin on 2022-05-18.
//
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)
}
struct SetupView: View {
@State private var eula = false
var body: some View {
NavigationView {
ZStack {
DamusGradient()
VStack(alignment: .center) {
NavigationLink(destination: EULAView(), isActive: $eula) {
EmptyView()
}
Image("logo-nobg")
.resizable()
.frame(width: 128.0, height: 128.0, alignment: .center)
.padding([.top], 20.0)
Text("Damus", comment: "Name of the app, shown on the first screen when user is not logged in.")
.font(Font.custom("Nunito", size: 50.0))
.kerning(-2)
.foregroundColor(.white)
CarouselView()
DamusWhiteButton(NSLocalizedString("Create Account", comment: "Button to create an account.")) {
self.state = .create_account
}
Button(NSLocalizedString("Login", comment: "Button to log into an account.")) {
self.state = .login
}
.padding([.top, .bottom], 20)
.foregroundColor(.white)
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationViewStyle(StackNavigationViewStyle())
}
}
func DamusWhiteButton(_ title: String, action: @escaping () -> ()) -> some View {
return Button(action: action) {
Text(title)
.frame(width: 300, height: 50)
.font(.body.bold())
.contentShape(Rectangle())
.foregroundColor(.white)
.background(
RoundedRectangle(cornerRadius: 4.0)
.stroke(Color.white, lineWidth: 2.0)
.background(Color.white.opacity(0.15))
)
struct LearnAboutNostrLink: View {
@Environment(\.openURL) var openURL
var body: some View {
HStack {
Button(action: {
openURL(URL(string: "https://nostr.com")!)
}, label: {
Text("Learn more about nostr")
.foregroundColor(.accentColor)
})
Image(systemName: "arrow.up.right")
.font(.footnote)
.foregroundColor(.accentColor)
}
}
}
struct WhatIsNostr: View {
var body: some View {
HStack(alignment: .top) {
Image("nostr-logo")
VStack(alignment: .leading) {
Text("What is nostr?")
.fontWeight(.bold)
.padding(.vertical, 10)
Text("Nostr is a protocol, designed for simplicity, that aims to create a censorship-resistant global social network")
.foregroundColor(DamusColors.mediumGrey)
LearnAboutNostrLink()
.padding(.top, 10)
}
}
}
}
}
}
struct SetupView_Previews: PreviewProvider {
static var previews: some View {
Group {
SetupView()
.previewDevice(PreviewDevice(rawValue: "iPhone SE (3rd generation)"))
SetupView()
.previewDevice(PreviewDevice(rawValue: "iPhone 13 Pro Max"))
}
}
}