mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-29 04:39:53 +00:00
* wip
* refactor, fix bindings
* wip
* wip
* fixes
* wip
* information map, logos
* global conditions hack
* restructure
* restructure
* texts
* text
* restructure
* wip
* restructure
* rename
* wip
* conditions for all
* comment
* onboarding wip
* onboarding wip
* fix paddings
* fix paddings
* wip
* fix padding
* onboarding wip
* nav link instead of sheet
* pretty button
* large titles
* notifications mode button style
* reenable demo operator
* Revert "reenable demo operator"
This reverts commit 42111eb333
.
* padding
* reenable demo operator
* refactor (removes additional model api)
* style
* bold
* bold
* light/dark
* fix button
* comment
* wip
* remove preset
* new types
* api types
* apis
* smp and xftp servers in single view
* test operator servers, refactor
* save in main view
* better progress
* better in progress
* remove shadow
* update
* apis
* conditions view wip
* load text
* remove custom servers button from onboarding, open already conditions in nav link
* allow to continue with simplex on onboarding
* footer
* existing users notice
* fix to not show nothing on no action
* disable notice
* review later
* disable notice
* wip
* wip
* wip
* wip
* optional tag
* fix
* fix tags
* fix
* wip
* remove coding keys
* fix onboarding
* rename
* rework model wip
* wip
* wip
* wip
* fix
* wip
* wip
* delete
* simplify
* wip
* fix delete
* ios: server operators ui wip
* refactor
* edited
* save servers on dismiss/back
* ios: add address card and remove address from onboarding (#5181)
* ios: add address card and remove address from onboarding
* allow for address creation in info when open via card
* conditions interactions wip
* conditions interactions wip
* fix
* wip
* wip
* wip
* wip
* rename
* wip
* fix
* remove operator binding
* fix set enabled
* rename
* cleanup
* text
* fix info view dark mode
* update lib
* ios: operators & servers validation
* fix
* ios: align onboarding style
* ios: align onboarding style
* ios: operators info (#5207)
* ios: operators info
* update
* update texts
* texts
---------
Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
---------
Co-authored-by: Diogo <diogofncunha@gmail.com>
Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
116 lines
4.1 KiB
Swift
116 lines
4.1 KiB
Swift
//
|
|
// AddressCreationCard.swift
|
|
// SimpleX (iOS)
|
|
//
|
|
// Created by Diogo Cunha on 13/11/2024.
|
|
// Copyright © 2024 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SimpleXChat
|
|
|
|
struct AddressCreationCard: View {
|
|
@EnvironmentObject var theme: AppTheme
|
|
@EnvironmentObject private var chatModel: ChatModel
|
|
@Environment(\.dynamicTypeSize) private var userFont: DynamicTypeSize
|
|
@AppStorage(DEFAULT_ADDRESS_CREATION_CARD_SHOWN) private var addressCreationCardShown = false
|
|
@State private var showAddressCreationAlert = false
|
|
@State private var showAddressSheet = false
|
|
@State private var showAddressInfoSheet = false
|
|
|
|
var body: some View {
|
|
let addressExists = chatModel.userAddress != nil
|
|
let chats = chatModel.chats.filter { chat in
|
|
!chat.chatInfo.chatDeleted && chatContactType(chat: chat) != ContactType.card
|
|
}
|
|
ZStack(alignment: .topTrailing) {
|
|
HStack(alignment: .top, spacing: 16) {
|
|
let envelopeSize = dynamicSize(userFont).profileImageSize
|
|
Image(systemName: "envelope.circle.fill")
|
|
.resizable()
|
|
.frame(width: envelopeSize, height: envelopeSize)
|
|
.foregroundColor(.accentColor)
|
|
VStack(alignment: .leading) {
|
|
Text("Your SimpleX address")
|
|
.font(.title3)
|
|
Spacer()
|
|
HStack(alignment: .center) {
|
|
Text("How to use it")
|
|
VStack {
|
|
Image(systemName: "info.circle")
|
|
.foregroundColor(theme.colors.secondary)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
VStack(alignment: .trailing) {
|
|
Image(systemName: "multiply")
|
|
.foregroundColor(theme.colors.secondary)
|
|
.onTapGesture {
|
|
showAddressCreationAlert = true
|
|
}
|
|
Spacer()
|
|
Text("Create")
|
|
.foregroundColor(.accentColor)
|
|
.onTapGesture {
|
|
showAddressSheet = true
|
|
}
|
|
}
|
|
}
|
|
.onTapGesture {
|
|
showAddressInfoSheet = true
|
|
}
|
|
.padding()
|
|
.background(theme.appColors.sentMessage)
|
|
.cornerRadius(12)
|
|
.frame(height: dynamicSize(userFont).rowHeight)
|
|
.padding(.vertical, 12)
|
|
.alert(isPresented: $showAddressCreationAlert) {
|
|
Alert(
|
|
title: Text("SimpleX address"),
|
|
message: Text("You can create it in user picker."),
|
|
dismissButton: .default(Text("Ok")) {
|
|
withAnimation {
|
|
addressCreationCardShown = true
|
|
}
|
|
}
|
|
)
|
|
}
|
|
.sheet(isPresented: $showAddressSheet) {
|
|
NavigationView {
|
|
UserAddressView(autoCreate: true)
|
|
.navigationTitle("SimpleX address")
|
|
.navigationBarTitleDisplayMode(.large)
|
|
.modifier(ThemedBackground(grouped: true))
|
|
}
|
|
}
|
|
.sheet(isPresented: $showAddressInfoSheet) {
|
|
NavigationView {
|
|
UserAddressLearnMore(showCreateAddressButton: true)
|
|
.navigationTitle("SimpleX address")
|
|
.navigationBarTitleDisplayMode(.large)
|
|
.modifier(ThemedBackground(grouped: true))
|
|
}
|
|
}
|
|
.onChange(of: addressExists) { exists in
|
|
if exists, !addressCreationCardShown {
|
|
addressCreationCardShown = true
|
|
}
|
|
}
|
|
.onChange(of: chats.count) { size in
|
|
if size >= 3, !addressCreationCardShown {
|
|
addressCreationCardShown = true
|
|
}
|
|
}
|
|
.onAppear {
|
|
if addressExists, !addressCreationCardShown {
|
|
addressCreationCardShown = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
AddressCreationCard()
|
|
}
|