Skip to content

Commit

Permalink
Merge branch 'development' into dev/feat/MOB-1840-mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Pecheneg committed Feb 26, 2024
2 parents fb2edb3 + c12cec0 commit d89d3b2
Show file tree
Hide file tree
Showing 31 changed files with 194 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ extension NetworkService {
imageType: nil,
coverPath: nil,
phoneNumber: nil,
domainPurchased: nil,
udBlue: nil),
domainPurchased: nil),
socialAccounts: nil,
referralCode: nil,
social: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11017,7 +11017,7 @@
repositoryURL = "https://github.com/Oleg-Pecheneg/push-swift-sdk";
requirement = {
kind = revision;
revision = ff3151a6834db9ca841ee0564979298f4b0df053;
revision = 7aa3a1aeea89acd91dcbefcb0473a2a993a66334;
};
};
C66811F02B47B0F500BDABB0 /* XCRemoteSwiftPackageReference "xmtp-ios" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Oleg-Pecheneg/push-swift-sdk",
"state" : {
"revision" : "ff3151a6834db9ca841ee0564979298f4b0df053"
"revision" : "7aa3a1aeea89acd91dcbefcb0473a2a993a66334"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ extension String {
case unableToCreateAccountTutorial
case referralTutorial
case referralLink(code: String)
case udBlue
case communitiesInfo
case setupApplePayInstruction
case unstoppableDomainSearch(searchKey: String)
Expand Down Expand Up @@ -92,8 +91,6 @@ extension String {
return "https://unstoppabledomains.com/refer-a-friend"
case .referralLink(let code):
return "\(NetworkConfig.migratedBaseUrl)/?ref=\(code)"
case .udBlue:
return "https://unstoppabledomains.com/products/blue"
case .communitiesInfo:
return "https://support.unstoppabledomains.com/support/solutions/articles/48001215751-badges"
case .setupApplePayInstruction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ extension UIImage {
static let cellChevron = UIImage(named: "cellChevron")!
static let udCartLogoRaster = UIImage(named: "udCartLogoRaster")!
static let chooseRRDomainIllustration = UIImage(named: "chooseRRDomainIllustration")!
static let udBlueGrayIcon = UIImage(named: "udBlueGrayIcon")!
static let check = UIImage(named: "check")!
static let statsIcon = UIImage(named: "statsIcon")!
static let sparkleIcon = UIImage(named: "sparkleIcon")!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ final class DomainProfileTopInfoCell: BaseDomainProfileTopInfoCell {
@IBOutlet private weak var domainNameLabel: UILabel!
@IBOutlet private weak var qrCodeButton: SmallRaisedTertiaryWhiteButton!
@IBOutlet private weak var followersButton: SmallRaisedTertiaryWhiteButton!
@IBOutlet private weak var udBlueImageView: UIImageView!

private let dropItemIdentifier = UTType.image.identifier

Expand Down Expand Up @@ -50,7 +49,6 @@ final class DomainProfileTopInfoCell: BaseDomainProfileTopInfoCell {
lineBreakMode: .byTruncatingTail)

followersButton.isHidden = false
udBlueImageView.isHidden = !data.isUDBlue
let social = data.social
let havingFollowers = social.followerCount > 0
let havingFollowings = social.followingCount > 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -72,21 +72,12 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="udBlueGrayIcon" translatesAutoresizingMaskIntoConstraints="NO" id="gBz-m9-G14">
<rect key="frame" x="56" y="56" width="24" height="24"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="SKV-pX-Qde"/>
<constraint firstAttribute="width" constant="24" id="vfO-s1-Pxs"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="8KU-Uo-7G0" firstAttribute="leading" secondItem="jcC-lZ-j5C" secondAttribute="leading" id="LCD-rE-dAi"/>
<constraint firstAttribute="trailing" secondItem="8KU-Uo-7G0" secondAttribute="trailing" id="MNG-BG-OB5"/>
<constraint firstAttribute="bottom" secondItem="gBz-m9-G14" secondAttribute="bottom" id="NMO-BR-tY8"/>
<constraint firstItem="8KU-Uo-7G0" firstAttribute="top" secondItem="jcC-lZ-j5C" secondAttribute="top" id="eVm-4H-iPV"/>
<constraint firstAttribute="trailing" secondItem="gBz-m9-G14" secondAttribute="trailing" id="lOc-Yy-u3N"/>
<constraint firstAttribute="bottom" secondItem="8KU-Uo-7G0" secondAttribute="bottom" id="sed-dw-MDK"/>
</constraints>
</view>
Expand Down Expand Up @@ -188,13 +179,11 @@
<outlet property="domainNameLabel" destination="LrO-nW-5kD" id="D9s-nG-i8V"/>
<outlet property="followersButton" destination="rHb-ab-50F" id="WLu-1c-e8x"/>
<outlet property="qrCodeButton" destination="GJQ-Ck-XLe" id="aLD-IN-eN1"/>
<outlet property="udBlueImageView" destination="gBz-m9-G14" id="jQ5-Pe-gh2"/>
</connections>
<point key="canvasLocation" x="272.30769230769232" y="38.388625592417057"/>
</collectionViewCell>
</objects>
<resources>
<image name="udBlueGrayIcon" width="25" height="26"/>
<namedColor name="brandUnstoppableBlue">
<color red="0.050980392156862744" green="0.40392156862745099" blue="0.99215686274509807" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ struct DomainProfileTopInfoData {
var imagePathPublic: Bool
var coverPathPublic: Bool
let social: DomainProfileSocialInfo
let isUDBlue: Bool

init(profile: SerializedUserDomainProfile) {
imagePathPublic = profile.profile.imagePathPublic
coverPathPublic = profile.profile.coverPathPublic
isUDBlue = profile.profile.udBlue ?? false
social = profile.social

if let avatarPath = profile.profile.imagePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extension DomainProfileViewController {
let id: UUID
let domain: DomainDisplayInfo
let social: DomainProfileSocialInfo
let isUDBlue: Bool
let isEnabled: Bool
let avatarImageState: DomainProfileTopInfoData.ImageState
let bannerImageState: DomainProfileTopInfoData.ImageState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ private extension PublicProfileView {
height: avatarSize)
.squareFrame(avatarSize)
.clipForAvatarStyle(avatarStyle)
if viewModel.isUDBlue {
Image.udBlueGrayIcon
.resizable()
.squareFrame(24)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ extension PublicProfileView {
@Published var socialAccounts: SocialAccounts?
@Published var error: Error?
@Published private(set) var isLoading = false
@Published private(set) var isUDBlue = false
@Published private(set) var isUserDomainSelected = true
@Published private(set) var profile: SerializedPublicDomainProfile?
@Published private(set) var badgesDisplayInfo: [DomainProfileBadgeDisplayInfo]?
Expand Down Expand Up @@ -165,7 +164,6 @@ extension PublicProfileView {
records = await convertRecordsFrom(recordsDict: profile.records ?? [:])
socialInfo = profile.social
socialAccounts = profile.socialAccounts
isUDBlue = profile.profile.udBlue ?? false
isLoading = false
loadImages()
}
Expand Down Expand Up @@ -300,8 +298,7 @@ extension PublicDomainProfileAttributes {
imageType: nil,
coverPath: nil,
phoneNumber: nil,
domainPurchased: nil,
udBlue: false)
domainPurchased: nil)

static let filled = PublicDomainProfileAttributes(displayName: "Oleg Kuplin",
description: "Unstoppable iOS developer",
Expand All @@ -311,8 +308,7 @@ extension PublicDomainProfileAttributes {
imageType: .onChain,
coverPath: "nil",
phoneNumber: nil,
domainPurchased: nil,
udBlue: false)
domainPurchased: nil)
}

func loadImageFrom(url: URL) async -> UIImage? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ extension DomainProfileTopInfoSection: DomainProfileSection {
func fill(snapshot: inout DomainProfileSnapshot, withGeneralData generalData: DomainProfileGeneralData) {
let domain = generalData.domain
let social = topInfoData.social
let isUDBlue = topInfoData.isUDBlue

let isEnabled = state == .default || state == .updatingRecords
snapshot.appendSections([.topInfo])

let itemData = DomainProfileViewController.ItemTopInfoData(id: id,
domain: domain,
social: social,
isUDBlue: isUDBlue,
isEnabled: isEnabled,
avatarImageState: editingTopInfoData.avatarImageState,
bannerImageState: editingTopInfoData.bannerImageState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct ChatView: View, ViewAnalyticsLogger {
ProgressView()
}
}
.environmentObject(viewModel)
.displayError($viewModel.error)
.background(Color.backgroundMuted2)
.onChange(of: viewModel.keyboardFocused) { keyboardFocused in
Expand All @@ -55,6 +54,9 @@ struct ChatView: View, ViewAnalyticsLogger {
.frame(maxWidth: .infinity)
}
}
.environmentObject(viewModel)
.environment(\.analyticsViewName, analyticsName)
.environment(\.analyticsAdditionalProperties, additionalAppearAnalyticParameters)
.onAppear(perform: onAppear)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final class ChatViewModel: ObservableObject, ViewAnalyticsLogger {
chatState = .loading
setupTitle()
setupPlaceholder()
setupFunctionality()
setIfUserCanSendAttachments()
loadAndShowData()
setListOfGroupParticipants()
}
Expand Down Expand Up @@ -356,9 +356,13 @@ private extension ChatViewModel {
}
}

func setupFunctionality() {
func setIfUserCanSendAttachments() {
let isProfileHasDomain = appContext.walletsDataService.wallets.findWithAddress(profile.wallet)?.rrDomain != nil
if isCommunityChat() {
canSendAttachments = featureFlagsService.valueFor(flag: .communityMediaEnabled)
let isCommunityMediaEnabled = featureFlagsService.valueFor(flag: .communityMediaEnabled)
canSendAttachments = isCommunityMediaEnabled && isProfileHasDomain
} else {
canSendAttachments = isProfileHasDomain
}
}

Expand Down Expand Up @@ -1020,7 +1024,7 @@ extension ChatViewModel: UDFeatureFlagsListener {
switch flag {
case .communityMediaEnabled:
if isCommunityChat() {
canSendAttachments = newValue
setIfUserCanSendAttachments()
reloadCachedMessages()
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct ExpandableTextEditor: View {
.foregroundStyle(Color.foregroundDefault)
.frame(height: max(40, textEditorHeight))
.scrollContentBackground(.hidden)
.padding(EdgeInsets(top: 0, leading: 8,
.padding(EdgeInsets(top: 4, leading: 8,
bottom: 0, trailing: 8))
.background(focused ? Color.backgroundMuted : Color.backgroundSubtle)
.tint(Color.foregroundAccent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import SwiftUI

struct MessageInputView: View {
struct MessageInputView: View, ViewAnalyticsLogger {

@Environment(\.analyticsViewName) var analyticsName
@Environment(\.analyticsAdditionalProperties) var additionalAppearAnalyticParameters
@EnvironmentObject var viewModel: ChatViewModel

let input: Binding<String>
let placeholder: String
@FocusState.Binding var focused: Bool
Expand All @@ -17,30 +21,13 @@ struct MessageInputView: View {

var body: some View {
HStack(alignment: .bottom, spacing: 16) {
Menu {
ForEach(AdditionalAction.allCases.filter { $0.isAvailable }, id: \.self) { action in
Button {
UDVibration.buttonTap.vibrate()
additionalActionCallback(action)
} label: {
Label(action.title, systemImage: action.icon)
}
}
} label: {
Image.plusIcon18
.resizable()
.squareFrame(20)
.padding(EdgeInsets(10))
.foregroundStyle(Color.foregroundSecondary)
}
.onButtonTap {
// logButtonPressedAnalyticEvents(button: action.analyticButton)
if viewModel.canSendAttachments {
additionalActionsView()
}

textFieldView()

if !input.wrappedValue.isEmpty {
Button {
UDVibration.buttonTap.vibrate()
sendCallback()
} label: {
Image.arrowUp24
Expand Down Expand Up @@ -88,11 +75,45 @@ struct MessageInputView: View {
return UnstoppableImagePicker.isCameraAvailable
}
}

var analyticButton: Analytics.Button {
switch self {
case .takePhoto:
return .takePhoto
case .choosePhoto:
return .choosePhoto
}
}
}
}

// MARK: - Private methods
private extension MessageInputView {
@MainActor
@ViewBuilder
func additionalActionsView() -> some View {
Menu {
ForEach(AdditionalAction.allCases.filter { $0.isAvailable }, id: \.self) { action in
Button {
UDVibration.buttonTap.vibrate()
logButtonPressedAnalyticEvents(button: action.analyticButton)
additionalActionCallback(action)
} label: {
Label(action.title, systemImage: action.icon)
}
}
} label: {
Image.plusIcon18
.resizable()
.squareFrame(20)
.padding(EdgeInsets(10))
.foregroundStyle(Color.foregroundSecondary)
}
.onButtonTap {
logButtonPressedAnalyticEvents(button: .chatInputActions)
}
}

@ViewBuilder
func textFieldView() -> some View {
ExpandableTextEditor(text: input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,28 @@ private extension ChatListChatRowView {

@ViewBuilder
func subtitleView() -> some View {
if let lastMessage = chat.lastMessage {
Text(lastMessageTextFrom(message: lastMessage))
if let subtitle = getSubtitleText() {
Text(subtitle)
.lineLimit(2)
.foregroundStyle(Color.foregroundSecondary)
.font(.currentFont(size: 14))
}
}

func getSubtitleText() -> String? {
if let lastMessage = chat.lastMessage {
return lastMessageTextFrom(message: lastMessage)
} else if case .community(let details) = chat.type {
switch details.type {
case .badge(let badgeDetailedInfo):
let holders = badgeDetailedInfo.usage.holders
let holdersKsString = holders.asFormattedKsString
return String.Constants.pluralNHolders.localized(holdersKsString, holders)
}
}
return nil
}

func lastMessageTextFrom(message: MessagingChatMessageDisplayInfo) -> String {
switch message.type {
case .text(let description):
Expand Down
Loading

0 comments on commit d89d3b2

Please sign in to comment.