Revert "WIP: swipe actions for global search screen"

This reverts commit 5894197306.
pull/891/head
Ryan ZHAO 1 year ago
parent 5894197306
commit e7c40ac04d

@ -27,7 +27,6 @@ abstract_target 'GlobalDependencies' do
pod 'NVActivityIndicatorView' pod 'NVActivityIndicatorView'
pod 'YYImage/libwebp', git: 'https://github.com/signalapp/YYImage' pod 'YYImage/libwebp', git: 'https://github.com/signalapp/YYImage'
pod 'DifferenceKit' pod 'DifferenceKit'
pod 'SwipeActions'
target 'SessionTests' do target 'SessionTests' do
inherit! :complete inherit! :complete

@ -44,7 +44,6 @@ PODS:
- SQLCipher/standard (4.5.3): - SQLCipher/standard (4.5.3):
- SQLCipher/common - SQLCipher/common
- SwiftProtobuf (1.5.0) - SwiftProtobuf (1.5.0)
- SwipeActions (0.3.3)
- WebRTC-lib (114.0.0) - WebRTC-lib (114.0.0)
- xcbeautify (0.17.0) - xcbeautify (0.17.0)
- YapDatabase/SQLCipher (3.1.1): - YapDatabase/SQLCipher (3.1.1):
@ -128,7 +127,6 @@ DEPENDENCIES:
- Sodium (from `https://github.com/oxen-io/session-ios-swift-sodium.git`, branch `session-build`) - Sodium (from `https://github.com/oxen-io/session-ios-swift-sodium.git`, branch `session-build`)
- SQLCipher (~> 4.5.3) - SQLCipher (~> 4.5.3)
- SwiftProtobuf (~> 1.5.0) - SwiftProtobuf (~> 1.5.0)
- SwipeActions
- WebRTC-lib - WebRTC-lib
- xcbeautify - xcbeautify
- YapDatabase/SQLCipher (from `https://github.com/oxen-io/session-ios-yap-database.git`, branch `signal-release`) - YapDatabase/SQLCipher (from `https://github.com/oxen-io/session-ios-yap-database.git`, branch `signal-release`)
@ -149,7 +147,6 @@ SPEC REPOS:
- SAMKeychain - SAMKeychain
- SQLCipher - SQLCipher
- SwiftProtobuf - SwiftProtobuf
- SwipeActions
- WebRTC-lib - WebRTC-lib
- xcbeautify - xcbeautify
@ -203,12 +200,11 @@ SPEC CHECKSUMS:
Sodium: a7d42cb46e789d2630fa552d35870b416ed055ae Sodium: a7d42cb46e789d2630fa552d35870b416ed055ae
SQLCipher: 57fa9f863fa4a3ed9dd3c90ace52315db8c0fdca SQLCipher: 57fa9f863fa4a3ed9dd3c90ace52315db8c0fdca
SwiftProtobuf: 241400280f912735c1e1b9fe675fdd2c6c4d42e2 SwiftProtobuf: 241400280f912735c1e1b9fe675fdd2c6c4d42e2
SwipeActions: 3c35871b408cab23ea67f3946a650356795250d2
WebRTC-lib: d83df8976fa608b980f1d85796b3de66d60a1953 WebRTC-lib: d83df8976fa608b980f1d85796b3de66d60a1953
xcbeautify: 6e2f57af5c3a86d490376d5758030a8dcc201c1b xcbeautify: 6e2f57af5c3a86d490376d5758030a8dcc201c1b
YapDatabase: b418a4baa6906e8028748938f9159807fd039af4 YapDatabase: b418a4baa6906e8028748938f9159807fd039af4
YYImage: f1ddd15ac032a58b78bbed1e012b50302d318331 YYImage: f1ddd15ac032a58b78bbed1e012b50302d318331
PODFILE CHECKSUM: 27f8a988cf382c38e480ea914df9d0899bab1ed9 PODFILE CHECKSUM: dd814a5a92577bb2a94dac6a1cc482f193721cdf
COCOAPODS: 1.15.0 COCOAPODS: 1.15.0

@ -8,7 +8,6 @@ import SessionMessagingKit
import SessionUtilitiesKit import SessionUtilitiesKit
import SignalUtilitiesKit import SignalUtilitiesKit
import SignalCoreKit import SignalCoreKit
import SwipeActions
enum SearchSection: Int, Differentiable { enum SearchSection: Int, Differentiable {
case noResults case noResults
@ -32,7 +31,6 @@ struct GlobalSearchScreen: View {
@State private var readConnection: Atomic<Database?> = Atomic(nil) @State private var readConnection: Atomic<Database?> = Atomic(nil)
@State private var termForCurrentSearchResultSet: String = "" @State private var termForCurrentSearchResultSet: String = ""
@State private var lastSearchText: String? @State private var lastSearchText: String?
@State private var swipeState: SwipeActions.SwipeState = .untouched
fileprivate static var defaultSearchResults: [SectionModel] = { fileprivate static var defaultSearchResults: [SectionModel] = {
let result: [SessionThreadViewModel]? = Storage.shared.read { db -> [SessionThreadViewModel]? in let result: [SessionThreadViewModel]? = Storage.shared.read { db -> [SessionThreadViewModel]? in
@ -189,50 +187,6 @@ struct GlobalSearchScreen: View {
}() }()
) )
} }
.addSwipeAction(
edge: .trailing,
state: $swipeState
) {
Button {
} label: {
VStack {
Image("icon_bin")
.renderingMode(.template)
.foregroundColor(themeColor: .textPrimary)
Text("TXT_DELETE_TITLE".localized())
.foregroundColor(themeColor: .textPrimary)
}
}
.frame(width: 60)
.frame(maxHeight: .infinity)
.contentShape(Rectangle())
.backgroundColor(themeColor: .danger)
}
Text("Text")
.addSwipeAction(
edge: .trailing,
state: $swipeState
) {
Button {
} label: {
VStack {
Image("icon_bin")
.renderingMode(.template)
.foregroundColor(themeColor: .textPrimary)
Text("TXT_DELETE_TITLE".localized())
.font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary)
}
}
.frame(width: 100)
.frame(maxHeight: .infinity)
.contentShape(Rectangle())
.backgroundColor(themeColor: .danger)
}
} }
} }
} }
@ -361,102 +315,102 @@ struct SearchResultCell: View {
var action: () -> Void var action: () -> Void
var body: some View { var body: some View {
HStack( Button {
alignment: .center, action()
spacing: Values.mediumSpacing } label: {
) { HStack(
let size: ProfilePictureView.Size = .list alignment: .center,
spacing: Values.mediumSpacing
ProfilePictureSwiftUI(
size: size,
publicKey: viewModel.threadId,
threadVariant: viewModel.threadVariant,
customImageData: viewModel.openGroupProfilePictureData,
profile: viewModel.profile,
additionalProfile: viewModel.additionalProfile
)
.frame(
width: size.viewSize,
height: size.viewSize,
alignment: .topLeading
)
.padding(.vertical, Values.smallSpacing)
VStack(
alignment: .leading,
spacing: Values.verySmallSpacing
) { ) {
HStack { let size: ProfilePictureView.Size = .list
Text(viewModel.displayName)
.bold() ProfilePictureSwiftUI(
.font(.system(size: Values.mediumFontSize)) size: size,
.foregroundColor(themeColor: .textPrimary) publicKey: viewModel.threadId,
threadVariant: viewModel.threadVariant,
Spacer() customImageData: viewModel.openGroupProfilePictureData,
profile: viewModel.profile,
if searchSection == .messages { additionalProfile: viewModel.additionalProfile
Text(viewModel.lastInteractionDate.formattedForDisplay) )
.font(.system(size: Values.smallFontSize)) .frame(
.foregroundColor(themeColor: .textSecondary) width: size.viewSize,
.opacity(Values.lowOpacity) height: size.viewSize,
alignment: .topLeading
)
.padding(.vertical, Values.smallSpacing)
VStack(
alignment: .leading,
spacing: Values.verySmallSpacing
) {
HStack {
Text(viewModel.displayName)
.bold()
.font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary)
Spacer()
if searchSection == .messages {
Text(viewModel.lastInteractionDate.formattedForDisplay)
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .textSecondary)
.opacity(Values.lowOpacity)
}
} }
}
if let textColor: UIColor = ThemeManager.currentTheme.color(for: .textPrimary) { if let textColor: UIColor = ThemeManager.currentTheme.color(for: .textPrimary) {
let maybeSnippet: NSAttributedString? = { let maybeSnippet: NSAttributedString? = {
switch searchSection { switch searchSection {
case .noResults, .defaultContacts: case .noResults, .defaultContacts:
return nil return nil
case .contactsAndGroups: case .contactsAndGroups:
switch viewModel.threadVariant { switch viewModel.threadVariant {
case .contact, .community: return nil case .contact, .community: return nil
case .legacyGroup, .group: case .legacyGroup, .group:
return self.getHighlightedSnippet( return self.getHighlightedSnippet(
content: (viewModel.threadMemberNames ?? ""), content: (viewModel.threadMemberNames ?? ""),
currentUserPublicKey: viewModel.currentUserPublicKey, currentUserPublicKey: viewModel.currentUserPublicKey,
currentUserBlinded15PublicKey: viewModel.currentUserBlinded15PublicKey, currentUserBlinded15PublicKey: viewModel.currentUserBlinded15PublicKey,
currentUserBlinded25PublicKey: viewModel.currentUserBlinded25PublicKey, currentUserBlinded25PublicKey: viewModel.currentUserBlinded25PublicKey,
searchText: searchText.lowercased(), searchText: searchText.lowercased(),
fontSize: Values.smallFontSize, fontSize: Values.smallFontSize,
textColor: textColor textColor: textColor
) )
}
case .messages:
return self.getHighlightedSnippet(
content: Interaction.previewText(
variant: (viewModel.interactionVariant ?? .standardIncoming),
body: viewModel.interactionBody,
authorDisplayName: viewModel.authorName(for: .contact),
attachmentDescriptionInfo: viewModel.interactionAttachmentDescriptionInfo,
attachmentCount: viewModel.interactionAttachmentCount,
isOpenGroupInvitation: (viewModel.interactionIsOpenGroupInvitation == true)
),
authorName: (viewModel.authorId != viewModel.currentUserPublicKey ?
viewModel.authorName(for: .contact) :
nil
),
currentUserPublicKey: viewModel.currentUserPublicKey,
currentUserBlinded15PublicKey: viewModel.currentUserBlinded15PublicKey,
currentUserBlinded25PublicKey: viewModel.currentUserBlinded25PublicKey,
searchText: searchText.lowercased(),
fontSize: Values.smallFontSize,
textColor: textColor
)
} }
case .messages: }()
return self.getHighlightedSnippet(
content: Interaction.previewText(
variant: (viewModel.interactionVariant ?? .standardIncoming),
body: viewModel.interactionBody,
authorDisplayName: viewModel.authorName(for: .contact),
attachmentDescriptionInfo: viewModel.interactionAttachmentDescriptionInfo,
attachmentCount: viewModel.interactionAttachmentCount,
isOpenGroupInvitation: (viewModel.interactionIsOpenGroupInvitation == true)
),
authorName: (viewModel.authorId != viewModel.currentUserPublicKey ?
viewModel.authorName(for: .contact) :
nil
),
currentUserPublicKey: viewModel.currentUserPublicKey,
currentUserBlinded15PublicKey: viewModel.currentUserBlinded15PublicKey,
currentUserBlinded25PublicKey: viewModel.currentUserBlinded25PublicKey,
searchText: searchText.lowercased(),
fontSize: Values.smallFontSize,
textColor: textColor
)
}
}()
if let snippet = maybeSnippet { if let snippet = maybeSnippet {
AttributedText(snippet).lineLimit(1) AttributedText(snippet).lineLimit(1)
}
} }
} }
}
Spacer(minLength: 0) Spacer(minLength: 0)
} }
.padding(.leading, Values.mediumSpacing) .padding(.leading, Values.mediumSpacing)
.contentShape(Rectangle())
.onTapGesture {
action()
} }
} }

Loading…
Cancel
Save