@@ -13,10 +13,11 @@ import CoreData
13
13
// MARK: - Localization
14
14
extension String . adamantLocalized {
15
15
struct chat {
16
- static let estimatedFeeFormat = NSLocalizedString ( " chat.estimatedFee " , comment: " Estimated fee: %f " )
16
+ static let estimatedFeeFormat = NSLocalizedString ( " chat.estimated-fee " , comment: " Estimated fee: %f " )
17
17
18
18
static let messageIsEmpty = NSLocalizedString ( " chat.message-is-empty " , comment: " Notify user that message cannot be empty " )
19
- static let messageTooLong = NSLocalizedString ( " chat.message-too-long " , comment: " Message is too long alert " )
19
+ static let messageTooLong = NSLocalizedString ( " chat.message-too-long " , comment: " Message is too long " )
20
+ static let notEnoughMoney = NSLocalizedString ( " chat.not-enough " , comment: " You don't have enough money to send a message. " )
20
21
21
22
static let internalErrorFormat = NSLocalizedString ( " chat.internal-error-format " , comment: " Internal error: %@ " )
22
23
static let serverErrorFormat = NSLocalizedString ( " chat.server-error-format " , comment: " Remote server error: %@ " )
@@ -137,7 +138,7 @@ class ChatViewController: MessagesViewController {
137
138
138
139
if let delegate = delegate, let address = chatroom. partner? . address, let message = delegate. getPreservedMessageFor ( address: address, thenRemoveIt: true ) {
139
140
messageInputBar. inputTextView. text = message
140
- setEstimatedFee ( feeCalculator. estimatedFeeFor ( message: message) )
141
+ setEstimatedFee ( feeCalculator. estimatedFeeFor ( message: AdamantMessage . text ( message) ) )
141
142
}
142
143
}
143
144
@@ -359,11 +360,20 @@ extension ChatViewController: MessageInputBarDelegate {
359
360
case . error( let error) :
360
361
let message : String
361
362
switch error {
362
- case . accountNotFound( let account) : message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, " Account not found: \( account) " )
363
- case . dependencyError( let error) : message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, error)
364
- case . internalError( let error) : message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, String ( describing: error) )
365
- case . notLogged: message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, " User not logged " )
366
- case . serverError( let error) : message = String . localizedStringWithFormat ( String . adamantLocalized. chat. serverErrorFormat, String ( describing: error) )
363
+ case . accountNotFound( let account) :
364
+ message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, " Account not found: \( account) " )
365
+ case . dependencyError( let error) :
366
+ message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, error)
367
+ case . internalError( let error) :
368
+ message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, String ( describing: error) )
369
+ case . notLogged:
370
+ message = String . localizedStringWithFormat ( String . adamantLocalized. chat. internalErrorFormat, " User not logged " )
371
+ case . serverError( let error) :
372
+ message = String . localizedStringWithFormat ( String . adamantLocalized. chat. serverErrorFormat, String ( describing: error) )
373
+
374
+ case . notEnoughtMoneyToSend:
375
+ message = String . adamantLocalized. chat. notEnoughMoney
376
+
367
377
case . messageNotValid( let problem) :
368
378
switch problem {
369
379
case . tooLong:
@@ -388,7 +398,7 @@ extension ChatViewController: MessageInputBarDelegate {
388
398
389
399
func messageInputBar( _ inputBar: MessageInputBar , textViewTextDidChangeTo text: String ) {
390
400
if text. count > 0 {
391
- let fee = feeCalculator. estimatedFeeFor ( message: text)
401
+ let fee = feeCalculator. estimatedFeeFor ( message: . text( text ) )
392
402
setEstimatedFee ( fee)
393
403
} else {
394
404
setEstimatedFee ( 0 )
0 commit comments