mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-04 06:56:12 +00:00
* types and db * migration module * chat tag * store method proposal * profiles build * update type * update return type * building * working api * update * refactor * attach tags to contact * simplify * attach chat tags to group info * get chat tags with supplied user id * get tags fix * ios: chat tags poc (#5370) * ios: chat tags poc * updates to sheet * temporary display for other option on swipe * sheet height * only show preset when it has matches * changes * worst emoji picker ever * simplify tag casts and collapse * open on create tag if no tags * simple emoji text field * nice emoji picker * dismiss sheets on tag/untag * semibold selection * all preset tag and change collapsed icon on selection * default selected tag (all) * only apply tag filters on empty search * + button when no custom lists * reset selection of tag filter on profile changes * edit tag (broken menu inside swiftui list) * create list to end of list * swipe changes * remove context menu * delete and edit on swipe actions * tap unread filter deselects other filters * remove delete tag if empty * show tag creation sheet when + button pressed * in memory tag edit * color, size * frame * layout * refactor * remove code * add unread to same unit * fraction on long press * nav fixes * in memory list * emoji picker improvements * remove diff * secondary plus * stop flickering on chat tags load * reuse string * fix reset glitches * delete destructive * simplify? * changes * api updates * fix styles on list via swipe * fixed untag * update schema * move user tags loading to get users chat data * move presets to model * update preset tags when chats are updated * style fixes and locate getPresetTags near tags model --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com> * deleted contacts and card should not match contact preset * fix update presets on chat remove * update migration indices * fix migration * not used chat model * disable button on repeated list name or emoji * no chats message for search fix * fix edits and trim * error in footer, not in alert * styling fixes due to wrong place to attach sheet * update library * remove log * idea for dynamic sheet height * max fraction 62% * minor fixes * disable save button when no changes and while saving * disable preset filter if it is no longer shown * remove comments from schema * fix emoji * remove apiChatTagsResponse * always read chat tags * fix --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com> Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
110 lines
3.9 KiB
Swift
110 lines
3.9 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 && !chat.chatInfo.contactCard
|
|
}
|
|
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()
|
|
Text("How to use it") + textSpace + Text(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)
|
|
.alert(isPresented: $showAddressCreationAlert) {
|
|
Alert(
|
|
title: Text("SimpleX address"),
|
|
message: Text("Tap Create SimpleX address in the menu to create it later."),
|
|
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("Address or 1-time link?")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.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()
|
|
}
|