2022-02-01 17:34:06 +00:00
//
// C h a t L i s t V i e w . s w i f t
// S i m p l e X
//
// C r e a t e d b y E v g e n y P o b e r e z k i n o n 2 7 / 0 1 / 2 0 2 2 .
// C o p y r i g h t © 2 0 2 2 S i m p l e X C h a t . A l l r i g h t s r e s e r v e d .
//
import SwiftUI
2022-05-31 07:55:13 +01:00
import SimpleXChat
2022-02-01 17:34:06 +00:00
2024-09-03 14:25:00 +01:00
enum UserPickerSheet : Identifiable {
case address
case chatPreferences
case chatProfiles
case currentProfile
case useFromDesktop
case settings
var id : Self { self }
}
2022-02-01 17:34:06 +00:00
struct ChatListView : View {
@ EnvironmentObject var chatModel : ChatModel
2024-07-03 22:42:13 +01:00
@ EnvironmentObject var theme : AppTheme
2023-04-12 12:22:55 +02:00
@ Binding var showSettings : Bool
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
@ State private var searchMode = false
@ FocusState private var searchFocussed
2022-02-13 08:45:08 +00:00
@ State private var searchText = " "
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
@ State private var searchShowingSimplexLink = false
@ State private var searchChatFilteredBySimplexLink : String ? = nil
2024-08-08 01:00:16 +03:00
@ State private var scrollToSearchBar = false
2024-09-03 14:25:00 +01:00
@ State private var activeUserPickerSheet : UserPickerSheet ? = nil
2024-09-04 22:42:44 +01:00
@ State private var userPickerShown : Bool = false
2024-09-04 20:56:56 +01:00
2023-06-19 11:13:30 +01:00
@ AppStorage ( DEFAULT_SHOW_UNREAD_AND_FAVORITES ) private var showUnreadAndFavorites = false
2024-08-07 01:33:48 +04:00
@ AppStorage ( GROUP_DEFAULT_ONE_HAND_UI , store : groupDefaults ) private var oneHandUI = true
@ AppStorage ( DEFAULT_ONE_HAND_UI_CARD_SHOWN ) private var oneHandUICardShown = false
2024-08-09 17:26:11 +01:00
@ AppStorage ( DEFAULT_TOOLBAR_MATERIAL ) private var toolbarMaterial = ToolbarMaterial . defaultMaterial
2024-08-07 01:33:48 +04:00
2022-02-01 17:34:06 +00:00
var body : some View {
2023-07-10 13:53:46 +01:00
if #available ( iOS 16.0 , * ) {
viewBody . scrollDismissesKeyboard ( . immediately )
} else {
viewBody
}
}
private var viewBody : some View {
2024-08-07 01:33:48 +04:00
ZStack ( alignment : oneHandUI ? . bottomLeading : . topLeading ) {
2023-01-23 18:45:24 +00:00
NavStackCompat (
isActive : Binding (
2023-10-31 09:44:57 +00:00
get : { chatModel . chatId != nil } ,
2024-08-11 00:23:56 +03:00
set : { active in
if ! active { chatModel . chatId = nil }
}
2023-01-23 18:45:24 +00:00
) ,
destination : chatView
2024-08-07 01:33:48 +04:00
) { chatListView }
2024-09-03 14:25:00 +01:00
}
2024-09-04 22:42:44 +01:00
. sheet ( isPresented : $ userPickerShown ) {
UserPicker {
userPickerShown = false
activeUserPickerSheet = $0
}
}
. sheet ( item : $ activeUserPickerSheet ) { sheet in
if let currentUser = chatModel . currentUser {
switch sheet {
case . address :
NavigationView {
UserAddressView ( shareViaProfile : currentUser . addressShared )
. navigationTitle ( " Public address " )
. navigationBarTitleDisplayMode ( . large )
. modifier ( ThemedBackground ( grouped : true ) )
}
case . chatProfiles :
NavigationView {
UserProfilesView ( )
2023-01-17 17:47:37 +00:00
}
2024-09-04 22:42:44 +01:00
case . currentProfile :
NavigationView {
UserProfile ( )
. navigationTitle ( " Your current profile " )
. modifier ( ThemedBackground ( ) )
}
case . chatPreferences :
NavigationView {
PreferencesView ( profile : currentUser . profile , preferences : currentUser . fullPreferences , currentPreferences : currentUser . fullPreferences )
. navigationTitle ( " Your preferences " )
. navigationBarTitleDisplayMode ( . large )
. modifier ( ThemedBackground ( grouped : true ) )
}
case . useFromDesktop :
ConnectDesktopView ( viaSettings : false )
case . settings :
SettingsView ( showSettings : $ showSettings )
. navigationBarTitleDisplayMode ( . large )
2024-09-04 20:56:56 +01:00
}
2024-09-04 22:42:44 +01:00
}
2022-09-21 15:11:52 +01:00
}
}
2023-05-26 15:49:26 +04:00
private var chatListView : some View {
2024-08-08 17:25:45 +01:00
let tm = ToolbarMaterial . material ( toolbarMaterial )
return withToolbar ( tm ) {
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
chatList
2024-08-07 01:33:48 +04:00
. background ( theme . colors . background )
. navigationBarTitleDisplayMode ( . inline )
. navigationBarHidden ( searchMode || oneHandUI )
2022-09-21 15:11:52 +01:00
}
2024-08-05 12:58:24 +01:00
. scaleEffect ( x : 1 , y : oneHandUI ? - 1 : 1 , anchor : . center )
2024-09-03 14:25:00 +01:00
. onDisappear ( ) { activeUserPickerSheet = nil }
2023-07-05 09:09:56 +01:00
. refreshable {
AlertManager . shared . showAlert ( Alert (
title : Text ( " Reconnect servers? " ) ,
message : Text ( " Reconnect all connected servers to force message delivery. It uses additional traffic. " ) ,
primaryButton : . default ( Text ( " Ok " ) ) {
Task {
do {
try await reconnectAllServers ( )
} catch let error {
AlertManager . shared . showAlertMsg ( title : " Error " , message : " \( responseError ( error ) ) " )
}
}
} ,
secondaryButton : . cancel ( )
) )
}
2024-08-07 01:33:48 +04:00
. safeAreaInset ( edge : . top ) {
2024-08-08 17:25:45 +01:00
if oneHandUI { Divider ( ) . background ( tm ) }
2024-08-07 01:33:48 +04:00
}
2024-08-07 18:24:15 +03:00
. safeAreaInset ( edge : . bottom ) {
if oneHandUI {
2024-08-08 17:25:45 +01:00
Divider ( ) . padding ( . bottom , Self . hasHomeIndicator ? 0 : 8 ) . background ( tm )
2024-08-07 18:24:15 +03:00
}
}
2024-08-05 12:58:24 +01:00
}
2024-08-07 01:33:48 +04:00
2024-08-07 18:24:15 +03:00
static var hasHomeIndicator : Bool = {
if let windowScene = UIApplication . shared . connectedScenes . first as ? UIWindowScene ,
let window = windowScene . windows . first {
window . safeAreaInsets . bottom > 0
} else { false }
} ( )
2024-08-08 17:25:45 +01:00
@ ViewBuilder func withToolbar ( _ material : Material , content : ( ) -> some View ) -> some View {
2024-08-07 01:33:48 +04:00
if #available ( iOS 16.0 , * ) {
if oneHandUI {
content ( )
2024-08-07 18:24:15 +03:00
. toolbarBackground ( . hidden , for : . bottomBar )
2024-08-07 01:33:48 +04:00
. toolbar { bottomToolbar }
} else {
content ( )
. toolbarBackground ( . automatic , for : . navigationBar )
2024-08-08 17:25:45 +01:00
. toolbarBackground ( material )
2024-08-07 01:33:48 +04:00
. toolbar { topToolbar }
2022-09-21 15:11:52 +01:00
}
2024-08-07 01:33:48 +04:00
} else {
if oneHandUI {
2024-08-08 01:00:16 +03:00
content ( ) . toolbar { bottomToolbarGroup }
2024-08-07 01:33:48 +04:00
} else {
content ( ) . toolbar { topToolbar }
}
}
}
@ ToolbarContentBuilder var topToolbar : some ToolbarContent {
ToolbarItem ( placement : . topBarLeading ) { leadingToolbarItem }
2024-08-07 18:24:15 +03:00
ToolbarItem ( placement : . principal ) { SubsStatusIndicator ( ) }
2024-08-07 01:33:48 +04:00
ToolbarItem ( placement : . topBarTrailing ) { trailingToolbarItem }
}
@ ToolbarContentBuilder var bottomToolbar : some ToolbarContent {
2024-08-08 01:00:16 +03:00
let padding : Double = Self . hasHomeIndicator ? 0 : 14
ToolbarItem ( placement : . bottomBar ) {
HStack {
leadingToolbarItem . padding ( . bottom , padding )
Spacer ( )
SubsStatusIndicator ( ) . padding ( . bottom , padding )
Spacer ( )
trailingToolbarItem . padding ( . bottom , padding )
}
. contentShape ( Rectangle ( ) )
. onTapGesture { scrollToSearchBar = true }
}
}
@ ToolbarContentBuilder var bottomToolbarGroup : some ToolbarContent {
2024-08-07 18:24:15 +03:00
let padding : Double = Self . hasHomeIndicator ? 0 : 14
ToolbarItemGroup ( placement : . bottomBar ) {
leadingToolbarItem . padding ( . bottom , padding )
Spacer ( )
SubsStatusIndicator ( ) . padding ( . bottom , padding )
Spacer ( )
trailingToolbarItem . padding ( . bottom , padding )
2024-08-07 01:33:48 +04:00
}
}
@ ViewBuilder var leadingToolbarItem : some View {
let user = chatModel . currentUser ? ? User . sampleData
ZStack ( alignment : . topTrailing ) {
ProfileImage ( imageStr : user . image , size : 32 , color : Color ( uiColor : . quaternaryLabel ) )
2024-09-03 14:25:00 +01:00
. padding ( [ . top , . trailing ] , 3 )
2024-08-07 01:33:48 +04:00
let allRead = chatModel . users
. filter { u in ! u . user . activeUser && ! u . user . hidden }
. allSatisfy { u in u . unreadCount = = 0 }
if ! allRead {
unreadBadge ( size : 12 )
}
}
. onTapGesture {
2024-09-04 22:42:44 +01:00
userPickerShown = true
2022-02-01 17:34:06 +00:00
}
2024-08-07 01:33:48 +04:00
}
@ ViewBuilder var trailingToolbarItem : some View {
switch chatModel . chatRunning {
case . some ( true ) : NewChatMenuButton ( )
case . some ( false ) : chatStoppedIcon ( )
case . none : EmptyView ( )
2024-08-05 12:58:24 +01:00
}
2022-09-21 15:11:52 +01:00
}
2022-02-13 08:45:08 +00:00
2023-06-27 10:28:47 +01:00
@ ViewBuilder private var chatList : some View {
let cs = filteredChats ( )
ZStack {
2024-08-08 01:00:16 +03:00
ScrollViewReader { scrollProxy in
List {
if ! chatModel . chats . isEmpty {
ChatListSearchBar (
searchMode : $ searchMode ,
searchFocussed : $ searchFocussed ,
searchText : $ searchText ,
searchShowingSimplexLink : $ searchShowingSimplexLink ,
searchChatFilteredBySimplexLink : $ searchChatFilteredBySimplexLink
)
2024-08-05 12:58:24 +01:00
. scaleEffect ( x : 1 , y : oneHandUI ? - 1 : 1 , anchor : . center )
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
. listRowSeparator ( . hidden )
2024-07-03 22:42:13 +01:00
. listRowBackground ( Color . clear )
2024-08-08 01:00:16 +03:00
. frame ( maxWidth : . infinity )
. padding ( . top , oneHandUI ? 8 : 0 )
. id ( " searchBar " )
}
if ! oneHandUICardShown {
OneHandUICard ( )
. scaleEffect ( x : 1 , y : oneHandUI ? - 1 : 1 , anchor : . center )
. listRowSeparator ( . hidden )
. listRowBackground ( Color . clear )
}
2024-08-20 15:54:52 +03:00
if #available ( iOS 16.0 , * ) {
ForEach ( cs , id : \ . viewId ) { chat in
ChatListNavLink ( chat : chat )
. scaleEffect ( x : 1 , y : oneHandUI ? - 1 : 1 , anchor : . center )
. padding ( . trailing , - 16 )
. disabled ( chatModel . chatRunning != true || chatModel . deletedChats . contains ( chat . chatInfo . id ) )
. listRowBackground ( Color . clear )
}
. offset ( x : - 8 )
} else {
ForEach ( cs , id : \ . viewId ) { chat in
VStack ( spacing : . zero ) {
Divider ( )
. padding ( . leading , 16 )
ChatListNavLink ( chat : chat )
. padding ( . horizontal , 8 )
. padding ( . vertical , 6 )
}
2024-08-08 01:00:16 +03:00
. scaleEffect ( x : 1 , y : oneHandUI ? - 1 : 1 , anchor : . center )
2024-08-20 15:54:52 +03:00
. listRowSeparator ( . hidden )
. listRowInsets ( EdgeInsets ( ) )
. background { theme . colors . background } // H i d e s d e f a u l t l i s t s e l e c t i o n c o l o u r
2024-08-08 01:00:16 +03:00
. disabled ( chatModel . chatRunning != true || chatModel . deletedChats . contains ( chat . chatInfo . id ) )
2024-08-20 15:54:52 +03:00
}
2024-08-08 01:00:16 +03:00
}
2023-06-27 10:28:47 +01:00
}
2024-08-08 01:00:16 +03:00
. listStyle ( . plain )
2024-08-10 14:04:37 +01:00
. onChange ( of : chatModel . chatId ) { currentChatId in
if let chatId = chatModel . chatToTop , currentChatId != chatId {
2024-08-08 01:00:16 +03:00
chatModel . chatToTop = nil
chatModel . popChat ( chatId )
}
stopAudioPlayer ( )
2024-08-07 01:33:48 +04:00
}
2024-08-08 01:00:16 +03:00
. onChange ( of : chatModel . currentUser ? . userId ) { _ in
stopAudioPlayer ( )
}
. onChange ( of : scrollToSearchBar ) { scrollToSearchBar in
if scrollToSearchBar {
Task { self . scrollToSearchBar = false }
withAnimation { scrollProxy . scrollTo ( " searchBar " ) }
}
2023-06-27 10:28:47 +01:00
}
}
if cs . isEmpty && ! chatModel . chats . isEmpty {
2024-08-05 12:58:24 +01:00
Text ( " No filtered chats " )
. scaleEffect ( x : 1 , y : oneHandUI ? - 1 : 1 , anchor : . center )
. foregroundColor ( . secondary )
2023-05-26 15:49:26 +04:00
}
}
}
2024-09-04 20:56:56 +01:00
private func unreadBadge ( size : CGFloat = 18 ) -> some View {
2023-01-20 13:17:41 +00:00
Circle ( )
. frame ( width : size , height : size )
2024-07-03 22:42:13 +01:00
. foregroundColor ( theme . colors . primary )
2023-01-20 13:17:41 +00:00
}
2022-12-30 21:47:11 +04:00
@ ViewBuilder private func chatView ( ) -> some View {
if let chatId = chatModel . chatId , let chat = chatModel . getChat ( chatId ) {
2024-07-03 10:24:26 +01:00
ChatView ( chat : chat )
2022-08-29 14:08:46 +01:00
}
}
2024-07-24 00:11:42 +07:00
func stopAudioPlayer ( ) {
VoiceItemState . smallView . values . forEach { $0 . audioPlayer ? . stop ( ) }
VoiceItemState . smallView = [ : ]
}
2022-02-13 08:45:08 +00:00
private func filteredChats ( ) -> [ Chat ] {
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
if let linkChatId = searchChatFilteredBySimplexLink {
return chatModel . chats . filter { $0 . id = = linkChatId }
} else {
let s = searchString ( )
return s = = " " && ! showUnreadAndFavorites
2024-08-05 12:58:24 +01:00
? chatModel . chats . filter { chat in
! chat . chatInfo . chatDeleted && chatContactType ( chat : chat ) != ContactType . card
}
2022-08-25 17:36:26 +04:00
: chatModel . chats . filter { chat in
2023-06-27 10:28:47 +01:00
let cInfo = chat . chatInfo
switch cInfo {
2022-08-25 17:36:26 +04:00
case let . direct ( contact ) :
2024-08-05 12:58:24 +01:00
return ! contact . chatDeleted && chatContactType ( chat : chat ) != ContactType . card && (
s = = " "
? filtered ( chat )
: ( viewNameContains ( cInfo , s ) ||
contact . profile . displayName . localizedLowercase . contains ( s ) ||
contact . fullName . localizedLowercase . contains ( s ) )
)
2023-06-27 10:28:47 +01:00
case let . group ( gInfo ) :
return s = = " "
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
? ( filtered ( chat ) || gInfo . membership . memberStatus = = . memInvited )
: viewNameContains ( cInfo , s )
2024-01-18 22:57:14 +07:00
case . local :
return s = = " " || viewNameContains ( cInfo , s )
2023-06-27 10:28:47 +01:00
case . contactRequest :
return s = = " " || viewNameContains ( cInfo , s )
case let . contactConnection ( conn ) :
return s != " " && conn . localAlias . localizedLowercase . contains ( s )
case . invalidJSON :
return false
2022-08-25 17:36:26 +04:00
}
2022-04-25 10:39:28 +01:00
}
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
}
func searchString ( ) -> String {
searchShowingSimplexLink ? " " : searchText . trimmingCharacters ( in : . whitespaces ) . localizedLowercase
}
2023-06-27 10:28:47 +01:00
func filtered ( _ chat : Chat ) -> Bool {
2024-03-12 17:33:28 +00:00
( chat . chatInfo . chatSettings ? . favorite ? ? false ) ||
chat . chatStats . unreadChat ||
( chat . chatInfo . ntfsEnabled && chat . chatStats . unreadCount > 0 )
2023-06-27 10:28:47 +01:00
}
func viewNameContains ( _ cInfo : ChatInfo , _ s : String ) -> Bool {
cInfo . chatViewName . localizedLowercase . contains ( s )
}
2022-02-01 17:34:06 +00:00
}
}
2024-07-03 16:59:46 +04:00
struct SubsStatusIndicator : View {
2024-07-22 19:32:54 +04:00
@ State private var subs : SMPServerSubs = SMPServerSubs . newSMPServerSubs
@ State private var hasSess : Bool = false
2024-08-17 15:26:56 +03:00
@ State private var task : Task < Void , Never > ?
2024-07-03 16:59:46 +04:00
@ State private var showServersSummary = false
2024-07-03 22:42:13 +01:00
2024-07-03 16:59:46 +04:00
@ AppStorage ( DEFAULT_SHOW_SUBSCRIPTION_PERCENTAGE ) private var showSubscriptionPercentage = false
var body : some View {
2024-08-06 20:31:45 +04:00
Button {
showServersSummary = true
} label : {
HStack ( spacing : 4 ) {
2024-08-07 18:24:15 +03:00
Text ( " Chats " ) . foregroundStyle ( Color . primary ) . fixedSize ( ) . font ( . headline )
2024-08-06 20:31:45 +04:00
SubscriptionStatusIndicatorView ( subs : subs , hasSess : hasSess )
if showSubscriptionPercentage {
SubscriptionStatusPercentageView ( subs : subs , hasSess : hasSess )
2024-07-03 16:59:46 +04:00
}
}
}
2024-08-13 13:14:27 +04:00
. disabled ( ChatModel . shared . chatRunning != true )
2024-07-03 16:59:46 +04:00
. onAppear {
2024-08-17 15:26:56 +03:00
startTask ( )
2024-07-03 16:59:46 +04:00
}
. onDisappear {
2024-08-17 15:26:56 +03:00
stopTask ( )
2024-07-03 16:59:46 +04:00
}
2024-08-06 12:03:25 +04:00
. appSheet ( isPresented : $ showServersSummary ) {
2024-07-22 19:32:54 +04:00
ServersSummaryView ( )
2024-08-06 12:03:25 +04:00
. environment ( \ EnvironmentValues . refresh as ! WritableKeyPath < EnvironmentValues , RefreshAction ? > , nil )
2024-07-03 16:59:46 +04:00
}
}
2024-08-17 15:26:56 +03:00
private func startTask ( ) {
task = Task {
while ! Task . isCancelled {
if AppChatState . shared . value = = . active {
do {
let ( subs , hasSess ) = try await getAgentSubsTotal ( )
await MainActor . run {
self . subs = subs
self . hasSess = hasSess
}
} catch let error {
logger . error ( " getSubsTotal error: \( responseError ( error ) ) " )
}
}
try ? await Task . sleep ( nanoseconds : 1_000_000_000 ) // S l e e p f o r 1 s e c o n d
2024-07-03 16:59:46 +04:00
}
}
}
2024-08-17 15:26:56 +03:00
func stopTask ( ) {
task ? . cancel ( )
task = nil
2024-07-03 16:59:46 +04:00
}
}
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
struct ChatListSearchBar : View {
@ EnvironmentObject var m : ChatModel
2024-07-03 22:42:13 +01:00
@ EnvironmentObject var theme : AppTheme
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
@ Binding var searchMode : Bool
@ FocusState . Binding var searchFocussed : Bool
@ Binding var searchText : String
@ Binding var searchShowingSimplexLink : Bool
@ Binding var searchChatFilteredBySimplexLink : String ?
@ State private var ignoreSearchTextChange = false
@ State private var alert : PlanAndConnectAlert ?
@ State private var sheet : PlanAndConnectActionSheet ?
2024-07-03 16:59:46 +04:00
@ AppStorage ( DEFAULT_SHOW_UNREAD_AND_FAVORITES ) private var showUnreadAndFavorites = false
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
var body : some View {
VStack ( spacing : 12 ) {
HStack ( spacing : 12 ) {
HStack ( spacing : 4 ) {
Image ( systemName : " magnifyingglass " )
TextField ( " Search or paste SimpleX link " , text : $ searchText )
2024-07-03 22:42:13 +01:00
. foregroundColor ( searchShowingSimplexLink ? theme . colors . secondary : theme . colors . onBackground )
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
. disabled ( searchShowingSimplexLink )
. focused ( $ searchFocussed )
. frame ( maxWidth : . infinity )
2023-12-30 14:09:07 +00:00
if ! searchText . isEmpty {
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
Image ( systemName : " xmark.circle.fill " )
. onTapGesture {
searchText = " "
}
}
}
. padding ( EdgeInsets ( top : 7 , leading : 7 , bottom : 7 , trailing : 7 ) )
2024-07-03 22:42:13 +01:00
. foregroundColor ( theme . colors . secondary )
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
. background ( Color ( . tertiarySystemFill ) )
. cornerRadius ( 10.0 )
if searchFocussed {
Text ( " Cancel " )
2024-07-03 22:42:13 +01:00
. foregroundColor ( theme . colors . primary )
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
. onTapGesture {
searchText = " "
searchFocussed = false
}
2024-07-03 16:59:46 +04:00
} else if m . chats . count > 0 {
toggleFilterButton ( )
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
}
}
}
. onChange ( of : searchFocussed ) { sf in
withAnimation { searchMode = sf }
}
. onChange ( of : searchText ) { t in
if ignoreSearchTextChange {
ignoreSearchTextChange = false
} else {
if let link = strHasSingleSimplexLink ( t . trimmingCharacters ( in : . whitespaces ) ) { // i f S i m p l e X l i n k i s p a s t e d , s h o w c o n n e c t i o n d i a l o g u e
searchFocussed = false
if case let . simplexLink ( linkType , _ , smpHosts ) = link . format {
ignoreSearchTextChange = true
searchText = simplexLinkText ( linkType , smpHosts )
}
searchShowingSimplexLink = true
searchChatFilteredBySimplexLink = nil
connect ( link . text )
} else {
if t != " " { // i f s o m e o t h e r t e x t i s p a s t e d , e n t e r s e a r c h m o d e
searchFocussed = true
}
searchShowingSimplexLink = false
searchChatFilteredBySimplexLink = nil
}
}
}
. alert ( item : $ alert ) { a in
planAndConnectAlert ( a , dismiss : true , cleanup : { searchText = " " } )
}
. actionSheet ( item : $ sheet ) { s in
planAndConnectActionSheet ( s , dismiss : true , cleanup : { searchText = " " } )
}
}
2024-07-03 16:59:46 +04:00
private func toggleFilterButton ( ) -> some View {
ZStack {
Color . clear
. frame ( width : 22 , height : 22 )
Image ( systemName : showUnreadAndFavorites ? " line.3.horizontal.decrease.circle.fill " : " line.3.horizontal.decrease " )
. resizable ( )
. scaledToFit ( )
2024-07-03 22:42:13 +01:00
. foregroundColor ( showUnreadAndFavorites ? theme . colors . primary : theme . colors . secondary )
2024-07-03 16:59:46 +04:00
. frame ( width : showUnreadAndFavorites ? 22 : 16 , height : showUnreadAndFavorites ? 22 : 16 )
. onTapGesture {
showUnreadAndFavorites = ! showUnreadAndFavorites
}
}
}
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
private func connect ( _ link : String ) {
planAndConnect (
link ,
showAlert : { alert = $0 } ,
showActionSheet : { sheet = $0 } ,
dismiss : false ,
incognito : nil ,
filterKnownContact : { searchChatFilteredBySimplexLink = $0 . id } ,
filterKnownGroup : { searchChatFilteredBySimplexLink = $0 . id }
)
}
}
2022-06-24 13:52:20 +01:00
func chatStoppedIcon ( ) -> some View {
Button {
AlertManager . shared . showAlertMsg (
title : " Chat is stopped " ,
message : " You can start chat via app Settings / Database or by restarting the app "
)
} label : {
Image ( systemName : " exclamationmark.octagon.fill " ) . foregroundColor ( . red )
}
}
2022-02-01 17:34:06 +00:00
struct ChatListView_Previews : PreviewProvider {
static var previews : some View {
let chatModel = ChatModel ( )
2024-08-20 09:29:52 +01:00
chatModel . updateChats ( [
ChatData (
2022-02-08 09:19:25 +00:00
chatInfo : ChatInfo . sampleData . direct ,
chatItems : [ ChatItem . getSample ( 1 , . directSnd , . now , " hello " ) ]
2022-02-01 17:34:06 +00:00
) ,
2024-08-20 09:29:52 +01:00
ChatData (
2022-02-08 09:19:25 +00:00
chatInfo : ChatInfo . sampleData . group ,
chatItems : [ ChatItem . getSample ( 1 , . directSnd , . now , " Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. " ) ]
2022-02-01 17:34:06 +00:00
) ,
2024-08-20 09:29:52 +01:00
ChatData (
2022-02-08 09:19:25 +00:00
chatInfo : ChatInfo . sampleData . contactRequest ,
2022-02-01 17:34:06 +00:00
chatItems : [ ]
)
2024-08-20 09:29:52 +01:00
] )
2022-02-11 07:42:00 +00:00
return Group {
2023-04-12 12:22:55 +02:00
ChatListView ( showSettings : Binding . constant ( false ) )
2022-02-11 07:42:00 +00:00
. environmentObject ( chatModel )
2023-04-12 12:22:55 +02:00
ChatListView ( showSettings : Binding . constant ( false ) )
2022-02-11 07:42:00 +00:00
. environmentObject ( ChatModel ( ) )
}
2022-02-01 17:34:06 +00:00
}
}