Skip to content

Commit

Permalink
[Electric-Coin-Company#1377] Add UA to memo
Browse files Browse the repository at this point in the history
- Checkbox for the UA being included to the memo implemented

[Electric-Coin-Company#1377] Add UA to memo

- Select text made as a separate and independent feature with final design and its own feature flag

[Electric-Coin-Company#1377] Add UA to memo

- design modified to encapsulate in a rounded background even the memoBytes label
  • Loading branch information
LukasKorba committed Oct 28, 2024
1 parent 3fe494a commit 90f8e4a
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 43 deletions.
1 change: 1 addition & 0 deletions modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ let package = Package(
"LocalAuthenticationHandler",
"Models",
"NumberFormatter",
"Models",
"SupportDataGenerator",
"Utils",
"ZcashSDKEnvironment",
Expand Down
3 changes: 3 additions & 0 deletions modules/Sources/Features/Root/RootInitialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ extension Root {
case .initialization(.initializationSuccessfullyDone(let uAddress)):
state.tabsState.receiveState.uAddress = uAddress
state.tabsState.settingsState.integrationsState.uAddress = uAddress
if let uAddress = try? uAddress?.stringEncoded {
state.tabsState.sendState.memoState.uAddress = uAddress
}
return .merge(
.send(.initialization(.registerForSynchronizersUpdate)),
.publisher {
Expand Down
2 changes: 1 addition & 1 deletion modules/Sources/Features/SendFlow/SendFlowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public struct SendFlowView: View {
}

if store.isMemoInputEnabled {
MessageEditorView(store: store.memoStore())
MessageEditorView(store: store.memoStore(), isAddUAtoMemoActive: true)
.frame(minHeight: 155)
.frame(maxHeight: 300)
.id(InputID.message)
Expand Down
12 changes: 12 additions & 0 deletions modules/Sources/Features/Tabs/TabsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public struct Tabs {
public var receiveState: Receive.State
public var requestZecState: RequestZec.State
public var selectedTab: Tab = .account
public var selectTextRequest = false
public var sendConfirmationState: SendConfirmation.State
public var sendState: SendFlow.State
public var settingsState: Settings.State
Expand All @@ -94,6 +95,7 @@ public struct Tabs {
public var stackDestinationMaxPrivacyBindingsAlive = 0
public var stackDestinationRequestPayment: StackDestinationRequestPayment?
public var stackDestinationRequestPaymentBindingsAlive = 0
public var textToSelect = ""
public var zecKeyboardState: ZecKeyboard.State

public init(
Expand Down Expand Up @@ -136,6 +138,7 @@ public struct Tabs {
case binding(BindingAction<Tabs.State>)
case currencyConversionCloseTapped
case currencyConversionSetup(CurrencyConversionSetup.Action)
case dismissSelectTextEditor
case home(Home.Action)
case onAppear
case rateTooltipTapped
Expand Down Expand Up @@ -307,6 +310,15 @@ public struct Tabs {
state.selectedTab = .balances
return .none

case .home(.transactionList(.selectText(let selectText))):
state.selectTextRequest = true
state.textToSelect = selectText
return .none

case .dismissSelectTextEditor:
state.selectTextRequest = false
return .none

case .home:
return .none

Expand Down
26 changes: 26 additions & 0 deletions modules/Sources/Features/Tabs/TabsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,32 @@ public struct TabsView: View {
.navigationBarItems(leading: hideBalancesButton(tab: store.selectedTab))
.zashiTitle { navBarView(store.selectedTab) }
.walletStatusPanel()
.sheet(isPresented: $store.selectTextRequest) {
VStack(alignment: .leading) {
HStack {
Spacer()

Button {
store.send(.dismissSelectTextEditor)
} label: {
Asset.Assets.buttonCloseX.image
.zImage(size: 24, style: Design.Btns.Tertiary.fg)
.padding(8)
.background {
RoundedRectangle(cornerRadius: 12)
.fill(Design.Btns.Tertiary.bg.color)
}
}
}

TextEditor(text: $store.textToSelect)
.colorBackground(Asset.Colors.background.color)
.background(Asset.Colors.background.color)
.zFont(size: 14, style: Design.Text.primary)
}
.padding()
.applyScreenBackground()
}
.overlayPreferenceValue(ExchangeRateStaleTooltipPreferenceKey.self) { preferences in
WithPerceptionTracking {
if store.isRateTooltipEnabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public struct TransactionList {
@ObservableState
public struct State: Equatable {
@Shared(.inMemory(.addressBookContacts)) public var addressBookContacts: AddressBookContacts = .empty
@Shared(.inMemory(.featureFlags)) public var featureFlags: FeatureFlags = .initial
public var latestMinedHeight: BlockHeight?
public var latestTransactionId = ""
public var latestTransactionList: [TransactionState] = []
Expand Down Expand Up @@ -45,6 +46,7 @@ public struct TransactionList {
case onAppear
case onDisappear
case saveAddressTapped(RedactableString)
case selectText(String)
case synchronizerStateChanged(SyncStatus)
case transactionCollapseRequested(String)
case transactionAddressExpandRequested(String)
Expand Down Expand Up @@ -124,6 +126,9 @@ public struct TransactionList {
.cancel(id: CancelEventId)
)

case .selectText:
return .none

case .saveAddressTapped:
return .none

Expand Down
24 changes: 22 additions & 2 deletions modules/Sources/Features/TransactionList/Views/MessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct MessageView: View {
ForEach(0..<memoTexts.count, id: \.self) { index in
VStack(alignment: .leading, spacing: 0) {
Color.clear.frame(height: 0)

Text(memoTexts[index])
.font(.custom(FontFamily.Inter.regular.name, size: 13))
.foregroundColor(
Expand All @@ -59,7 +59,27 @@ struct MessageView: View {
.stroke(Design.Surfaces.strokePrimary.color)
}

TapToCopyTransactionDataView(store: store, data: memoTexts[index].redacted)
if store.featureFlags.selectText {
HStack(spacing: 0) {
TapToCopyTransactionDataView(store: store, data: memoTexts[index].redacted)

Button {
store.send(.selectText(memoTexts[index]))
} label: {
HStack {
Asset.Assets.Icons.textInput.image
.zImage(size: 16, style: Design.Btns.Tertiary.fg)

Text(L10n.Transaction.selectText)
.zFont(.semiBold, size: 14, style: Design.Btns.Tertiary.fg)
}
}
.buttonStyle(.borderless)
.padding(.leading, 24)
}
} else {
TapToCopyTransactionDataView(store: store, data: memoTexts[index].redacted)
}
}
.padding(.bottom, 20)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct TapToCopyTransactionDataView: View {
} label: {
HStack {
Asset.Assets.copy.image
.zImage(size: 11, style: Design.Btns.Tertiary.fg)
.zImage(size: 16, style: Design.Btns.Tertiary.fg)

Text(L10n.General.tapToCopy)
.zFont(.semiBold, size: 14, style: Design.Btns.Tertiary.fg)
Expand Down
13 changes: 13 additions & 0 deletions modules/Sources/Generated/L10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,17 @@ public enum L10n {
/// The Following content requires authentication.
public static let reason = L10n.tr("Localizable", "localAuthentication.reason", fallback: "The Following content requires authentication.")
}
public enum MessageEditor {
/// Reply-to: Include my address in the memo
public static let addUA = L10n.tr("Localizable", "messageEditor.addUA", fallback: "Reply-to: Include my address in the memo")
///
/// >>> reply-to: %@
public static func addUAformat(_ p1: Any) -> String {
return L10n.tr("Localizable", "messageEditor.addUAformat", String(describing: p1), fallback: "\n>>> reply-to: %@")
}
/// Your address is included in the memo
public static let removeUA = L10n.tr("Localizable", "messageEditor.removeUA", fallback: "Your address is included in the memo")
}
public enum NotEnoughFreeSpace {
/// Zashi requires at
/// least %@ GB of space to
Expand Down Expand Up @@ -893,6 +904,8 @@ public enum L10n {
public static let receiving = L10n.tr("Localizable", "transaction.receiving", fallback: "Receiving...")
/// Save address
public static let saveAddress = L10n.tr("Localizable", "transaction.saveAddress", fallback: "Save address")
/// Select text
public static let selectText = L10n.tr("Localizable", "transaction.selectText", fallback: "Select text")
/// Sending...
public static let sending = L10n.tr("Localizable", "transaction.sending", fallback: "Sending...")
/// Sent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "textInput.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions modules/Sources/Generated/Resources/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ Sharing this private data is irrevocable — once you have shared this private d
"transaction.shieldedFunds" = "Shielded Funds";
"transaction.failedShieldedFunds" = "Shielded Funds Failed";
"transaction.saveAddress" = "Save address";
"transaction.selectText" = "Select text";

// MARK: - Local authentication
"localAuthentication.reason" = "The Following content requires authentication.";
Expand Down Expand Up @@ -346,6 +347,11 @@ Sharing this private data is irrevocable — once you have shared this private d
"exportLogs.alert.failed.title" = "Error when exporting logs";
"exportLogs.alert.failed.message" = "Error: %@";

// MARK: - Message Editor
"messageEditor.addUA" = "Reply-to: Include my address in the memo";
"messageEditor.removeUA" = "Your address is included in the memo";
"messageEditor.addUAformat" = "\n>>> reply-to: %@";

// MARK: - Address Book
"addressBook.title" = "Address Book";
"addressBook.newContact.title" = "Add New Address";
Expand Down
1 change: 1 addition & 0 deletions modules/Sources/Generated/XCAssets+Generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public enum Asset {
public static let share = ImageAsset(name: "share")
public static let shieldTickFilled = ImageAsset(name: "shieldTickFilled")
public static let switchHorizontal = ImageAsset(name: "switchHorizontal")
public static let textInput = ImageAsset(name: "textInput")
public static let user = ImageAsset(name: "user")
public static let userPlus = ImageAsset(name: "userPlus")
}
Expand Down
12 changes: 9 additions & 3 deletions modules/Sources/Models/FeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@
//

public struct FeatureFlags: Equatable {
public let flexa: Bool
public let addUAtoMemo: Bool
public let appLaunchBiometric: Bool
public let flexa: Bool
public let selectText: Bool

public init(
addUAtoMemo: Bool = false,
appLaunchBiometric: Bool = false,
flexa: Bool = false,
appLaunchBiometric: Bool = false
selectText: Bool = false
) {
self.flexa = flexa
self.addUAtoMemo = addUAtoMemo
self.appLaunchBiometric = appLaunchBiometric
self.flexa = flexa
self.selectText = selectText
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,61 +26,62 @@ public struct MessageEditorView: View {

let title: String
let placeholder: String
let isAddUAtoMemoActive: Bool

@FocusState public var isFocused: Bool

public init(
store: StoreOf<MessageEditor>,
title: String = L10n.Send.message,
placeholder: String = L10n.Send.memoPlaceholder
placeholder: String = L10n.Send.memoPlaceholder,
isAddUAtoMemoActive: Bool = false
) {
self.store = store
self.title = title
self.placeholder = placeholder
self.isAddUAtoMemoActive = isAddUAtoMemoActive
self.isFocused = false
}

public var body: some View {
WithPerceptionTracking {
VStack(alignment: .leading, spacing: 0) {
Text(title)
.font(.custom(FontFamily.Inter.medium.name, size: 14))
.foregroundColor(Design.Inputs.Filled.label.color)
.zFont(.medium, size: 14, style: Design.Inputs.Filled.label)
.padding(.bottom, 6)

TextEditor(text: $store.text)
.focused($isFocused)
.font(.custom(FontFamily.Inter.regular.name, size: 16))
.padding(.horizontal, 10)
.padding(.top, 2)
.padding(.bottom, 10)
.colorBackground(Design.Inputs.Default.bg.color)
.background(Design.Inputs.Default.bg.color)
.cornerRadius(10)
.overlay {
if store.text.isEmpty {
HStack {
VStack {
Text(placeholder)
.font(.custom(FontFamily.Inter.regular.name, size: 16))
.foregroundColor(Design.Inputs.Default.text.color)
.onTapGesture {
isFocused = true
}
VStack(spacing: 0) {
TextEditor(text: $store.text)
.focused($isFocused)
.font(.custom(FontFamily.Inter.regular.name, size: 16))
.padding(.horizontal, 10)
.padding(.top, 2)
.padding(.bottom, 10)
.colorBackground(Design.Inputs.Default.bg.color)
.cornerRadius(10)
.overlay {
if store.text.isEmpty {
HStack {
VStack {
Text(placeholder)
.font(.custom(FontFamily.Inter.regular.name, size: 16))
.foregroundColor(Design.Inputs.Default.text.color)
.onTapGesture {
isFocused = true
}

Spacer()
}
.padding(.top, 10)

Spacer()
}
.padding(.top, 10)
Spacer()
.padding(.leading, 14)
} else {
EmptyView()
}
.padding(.leading, 14)
} else {
EmptyView()
}
}

if store.isCharLimited {

HStack {
Spacer()

Expand All @@ -91,10 +92,25 @@ public struct MessageEditorView: View {
? Design.Inputs.Default.hint.color
: Design.Inputs.Filled.required.color
)
.padding(.trailing, 14)
.padding(.bottom, 14)
}
.frame(height: 20)
.padding(.top, 4)
}
.background {
RoundedRectangle(cornerRadius: 10)
.fill(Design.Inputs.Default.bg.color)
}

if store.featureFlags.addUAtoMemo && isAddUAtoMemoActive && !store.uAddress.isEmpty {
ZashiToggle(
isOn: $store.isUAaddedToMemo,
label: store.isUAaddedToMemo ? L10n.MessageEditor.addUA : L10n.MessageEditor.addUA,
textColor: Design.Inputs.Filled.label.color
)
.padding(.top, 12)
}
}
}
}
Expand Down
Loading

0 comments on commit 90f8e4a

Please sign in to comment.