Skip to content

Commit 2ec448d

Browse files
committed
Merge branch 'release/0.2.7'
2 parents 2f0dd0c + dee85e5 commit 2ec448d

File tree

14 files changed

+142
-38
lines changed

14 files changed

+142
-38
lines changed

Adamant/AppDelegate.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import SwinjectStoryboard
1414
class AppDelegate: UIResponder, UIApplicationDelegate {
1515

1616
var window: UIWindow?
17+
var repeater: RepeaterService!
1718

1819
// MARK: - Lifecycle
1920

@@ -60,7 +61,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6061

6162
// MARK: 4 Autoupdate
6263
let chatsProvider = container.resolve(ChatsProvider.self)!
63-
let repeater = RepeaterService()
64+
repeater = RepeaterService()
6465
repeater.registerForegroundCall(label: "chatsProvider", interval: 3, queue: DispatchQueue.global(qos: .utility), callback: chatsProvider.update)
6566

6667

@@ -77,4 +78,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
7778

7879
return true
7980
}
81+
82+
func applicationWillResignActive(_ application: UIApplication) {
83+
repeater.pauseAll()
84+
}
85+
86+
func applicationDidEnterBackground(_ application: UIApplication) {
87+
repeater.pauseAll()
88+
}
89+
90+
func applicationDidBecomeActive(_ application: UIApplication) {
91+
repeater.resumeAll()
92+
}
8093
}
Loading
Loading
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "Arrow.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"filename" : "Arrow@2x.png",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "universal",
15+
"filename" : "Arrow@3x.png",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"version" : 1,
21+
"author" : "xcode"
22+
}
23+
}
Loading
Loading
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "Arrow_innactive.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"filename" : "Arrow_innactive@2x.png",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "universal",
15+
"filename" : "Arrow_innactive@3x.png",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"version" : 1,
21+
"author" : "xcode"
22+
}
23+
}

Adamant/Assets/ru.lproj/Localizable.strings

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
/* Shared alert Done message. Used anywhere */
5555
"Done" = "Готово";
5656

57+
/* Wallet page: Inform user that sending tokens not allowed by Apple until the end of ICO */
58+
"Due to Apple restrictions, sending tokens is not allowed until the end of the ICO. For now, you can send tokens using WebApp at msg.adamant.im" = "Ввиду ограничений Apple, отправка токенов отключена до конца ICO. В данный момент вы можете отправлять токены с помощью WebApp по адресу msg.adamant.im";
59+
5760
/* Login: notify user that he is trying to login without a passphrase */
5861
"Enter a passphrase!" = "Введите пароль";
5962

@@ -64,7 +67,7 @@
6467
"Error" = "Ошибка";
6568

6669
/* Chat: input bar: Estimated fee */
67-
"Estimated fee: %@" = "Ориентировочная комиссия: %@";
70+
"Estimated fee: %@" = "Примерная комиссия: %@";
6871

6972
/* Transaction details: fee row. */
7073
"Fee" = "Комиссия";
@@ -84,6 +87,9 @@
8487
/* Login: generate new passphrase button */
8588
"Generate new passphrase" = "Создать новый";
8689

90+
/* Wallet page: 'Transfer not allowed' alert 'go to WebApp button' */
91+
"Go to msg.adamant.im" = "Открыть msg.adamant.im";
92+
8793
/* Transaction details: Id row. */
8894
"Id" = "Номер";
8995

@@ -177,6 +183,9 @@
177183
/* Shared alert 'Settings' button. Used to go to system Settings app, on application settings page. Should be same as Settings application title. */
178184
"Settings" = "Настройки";
179185

186+
/* Wallet page: 'Transfer not allowed' alert title */
187+
"Sorry!" = "Ой!";
188+
180189
/* Shared alert 'Share' button. Used anywhere for presenting standart iOS 'Share' menu. */
181190
"Share" = "Поделиться";
182191

Adamant/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.2.6</string>
20+
<string>0.2.7</string>
2121
<key>CFBundleVersion</key>
22-
<string>13</string>
22+
<string>14</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>NSCameraUsageDescription</key>

Adamant/Services/RepeaterService.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ class RepeaterService {
6868
func pauseAll() {
6969
pauseSemaphore.wait()
7070

71-
if isPaused { return }
71+
defer {
72+
pauseSemaphore.signal()
73+
}
74+
75+
if isPaused {
76+
return
77+
}
7278

7379
DispatchQueue.main.async {
7480
for (_, client) in self.foregroundTimers {
@@ -78,14 +84,18 @@ class RepeaterService {
7884
}
7985

8086
isPaused = true
81-
82-
pauseSemaphore.signal()
8387
}
8488

85-
func resume() {
89+
func resumeAll() {
8690
pauseSemaphore.wait()
8791

88-
if !isPaused { return }
92+
defer {
93+
pauseSemaphore.signal()
94+
}
95+
96+
if !isPaused {
97+
return
98+
}
8999

90100
DispatchQueue.main.async {
91101
for (_, client) in self.foregroundTimers {
@@ -96,8 +106,6 @@ class RepeaterService {
96106
}
97107

98108
isPaused = false
99-
100-
pauseSemaphore.signal()
101109
}
102110

103111
@objc private func timerFired(timer: Timer) {

Adamant/Stories/Account/AccountViewController.swift

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ extension String.adamantLocalized {
1818
static let rowInvest = NSLocalizedString("Invest in ICO", comment: "Wallet page: 'Invest in ICO' button")
1919
static let rowLogout = NSLocalizedString("Logout", comment: "Wallet page: 'Logout' button")
2020

21+
static let sorryAlert = NSLocalizedString("Sorry!", comment: "Wallet page: 'Transfer not allowed' alert title")
22+
static let webApp = NSLocalizedString("Go to msg.adamant.im", comment: "Wallet page: 'Transfer not allowed' alert 'go to WebApp button'")
23+
static let transferNotAllowed = NSLocalizedString("Due to Apple restrictions, sending tokens is not allowed until the end of the ICO. For now, you can send tokens using WebApp at msg.adamant.im", comment: "Wallet page: Inform user that sending tokens not allowed by Apple until the end of ICO")
24+
2125
static let sectionAccount = NSLocalizedString("Account", comment: "Wallet page: Account section title.")
2226
static let sectionWallet = NSLocalizedString("Wallet", comment: "Wallet page: Wallet section title")
2327
static let sectionActions = NSLocalizedString("Actions", comment: "Wallet page: Actions section title")
@@ -39,16 +43,18 @@ class AccountViewController: UIViewController {
3943
private let showTransactionsSegue = "showTransactions"
4044
private let showTransferSegue = "showTransfer"
4145

46+
private let webAppUrl = URL.init(string: "https://msg.adamant.im")
47+
4248
private enum Sections: Int {
4349
case account = 0, wallet, actions
4450

4551
static let total = 3
4652
}
4753

4854
private enum WalletRows: Int {
49-
case balance, /*sendTokens, */ invest
55+
case balance, sendTokens, invest
5056

51-
static let total = 2
57+
static let total = 3
5258
}
5359

5460

@@ -177,8 +183,25 @@ extension AccountViewController: UITableViewDataSource, UITableViewDelegate {
177183
case .balance:
178184
performSegue(withIdentifier: showTransactionsSegue, sender: nil)
179185

180-
// case .sendTokens:
186+
case .sendTokens:
181187
// performSegue(withIdentifier: showTransferSegue, sender: nil)
188+
// <Sending funds not allowed>
189+
let alert = UIAlertController(title: String.adamantLocalized.account.sorryAlert, message: String.adamantLocalized.account.transferNotAllowed, preferredStyle: .alert)
190+
191+
alert.addAction(UIAlertAction(title: String.adamantLocalized.alert.cancel, style: .cancel, handler: nil))
192+
193+
if let url = self.webAppUrl {
194+
alert.addAction(UIAlertAction(title: String.adamantLocalized.account.webApp, style: .default, handler: { [weak self] _ in
195+
let safari = SFSafariViewController(url: url)
196+
safari.preferredControlTintColor = UIColor.adamantPrimary
197+
self?.present(safari, animated: true, completion: nil)
198+
}))
199+
}
200+
201+
present(alert, animated: true, completion: { [weak self] in
202+
self?.tableView.deselectRow(at: indexPath, animated: true)
203+
})
204+
// </Sending funds not allowed>
182205

183206
case .invest:
184207
guard let address = accountService.account?.address,
@@ -253,10 +276,10 @@ extension AccountViewController {
253276
cell.detailTextLabel?.text = AdamantUtilities.format(balance: account.balance)
254277
cell.imageView?.image = nil
255278

256-
// case .sendTokens:
257-
// cell.textLabel?.text = String.adamantLocalized.account.rowSendTokens
258-
// cell.detailTextLabel?.text = nil
259-
// cell.imageView?.image = nil
279+
case .sendTokens:
280+
cell.textLabel?.text = String.adamantLocalized.account.rowSendTokens
281+
cell.detailTextLabel?.text = nil
282+
cell.imageView?.image = nil
260283

261284
case .invest:
262285
cell.textLabel?.text = String.adamantLocalized.account.rowInvest

Adamant/Stories/Chats/ChatViewController.swift

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,9 @@ class ChatViewController: MessagesViewController {
6767
override func viewDidLoad() {
6868
super.viewDidLoad()
6969

70-
guard let chatroom = chatroom else {
71-
print("Failed to get chat controller")
72-
return
73-
}
74-
7570
// MARK: 1. Initial configuration
7671

77-
if let partner = chatroom.partner {
72+
if let partner = chatroom?.partner {
7873
if let name = partner.name {
7974
self.navigationItem.title = name
8075
} else {
@@ -88,7 +83,7 @@ class ChatViewController: MessagesViewController {
8883
maintainPositionOnKeyboardFrameChanged = true
8984

9085
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
91-
guard let controller = self?.chatsProvider.getChatController(for: chatroom) else {
86+
guard let chatroom = self?.chatroom, let controller = self?.chatsProvider.getChatController(for: chatroom) else {
9287
return
9388
}
9489

@@ -110,36 +105,49 @@ class ChatViewController: MessagesViewController {
110105

111106
let bordersColor = UIColor(red: 200/255, green: 200/255, blue: 200/255, alpha: 1)
112107
let size: CGFloat = 6.0
108+
let buttonHeight: CGFloat = 36
109+
let buttonWidth: CGFloat = 46
113110

111+
// Text & Colors
114112
messageInputBar.inputTextView.placeholder = String.adamantLocalized.chat.messageInputPlaceholder
115113
messageInputBar.separatorLine.backgroundColor = bordersColor
116114
messageInputBar.inputTextView.placeholderTextColor = UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1)
117-
messageInputBar.inputTextView.textContainerInset = UIEdgeInsets(top: size, left: size*2, bottom: size, right: size*2)
118-
messageInputBar.inputTextView.placeholderLabelInsets = UIEdgeInsets(top: size, left: size*2+4, bottom: size, right: size*2+4)
119115
messageInputBar.inputTextView.layer.borderColor = bordersColor.cgColor
120116
messageInputBar.inputTextView.layer.borderWidth = 1.0
121117
messageInputBar.inputTextView.layer.cornerRadius = size*2
122118
messageInputBar.inputTextView.layer.masksToBounds = true
119+
120+
// Insets
121+
messageInputBar.inputTextView.textContainerInset = UIEdgeInsets(top: size, left: size*2, bottom: size, right: buttonWidth + size/2)
122+
messageInputBar.inputTextView.placeholderLabelInsets = UIEdgeInsets(top: size, left: size*2+4, bottom: size, right: buttonWidth + size/2+2)
123123
messageInputBar.inputTextView.scrollIndicatorInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
124+
messageInputBar.textViewPadding.right = -buttonWidth
124125

125-
messageInputBar.setStackViewItems([], forStack: .right, animated: false)
126-
messageInputBar.setRightStackViewWidthConstant(to: 0, animated: false)
126+
messageInputBar.setRightStackViewWidthConstant(to: buttonWidth, animated: false)
127127

128+
// Make feeLabel
128129
let feeLabel = InputBarButtonItem()
129130
self.feeLabel = feeLabel
130131
feeLabel.isEnabled = false
131132
feeLabel.titleLabel?.font = UIFont.adamantPrimary(size: 12)
132133
feeLabel.alpha = 0
133-
feeLabel.isHidden = true
134134

135-
messageInputBar.setStackViewItems([feeLabel, .flexibleSpace, messageInputBar.sendButton], forStack: .bottom, animated: false)
135+
// Setup stack views
136+
messageInputBar.setStackViewItems([messageInputBar.sendButton], forStack: .right, animated: false)
137+
messageInputBar.setStackViewItems([feeLabel, .flexibleSpace], forStack: .bottom, animated: false)
138+
136139
messageInputBar.sendButton.configure {
137-
$0.setTitleColor(UIColor.adamantPrimary, for: .normal)
138-
$0.setTitleColor(UIColor.adamantSecondary, for: .highlighted)
139-
$0.title = String.adamantLocalized.chat.sendButton
140+
141+
$0.layer.cornerRadius = size*2
142+
$0.layer.borderWidth = 1
143+
$0.layer.borderColor = bordersColor.cgColor
144+
$0.setSize(CGSize(width: buttonWidth, height: buttonHeight), animated: false)
145+
$0.title = nil
146+
$0.image = #imageLiteral(resourceName: "Arrow")
147+
$0.setImage(#imageLiteral(resourceName: "Arrow_innactive"), for: UIControlState.disabled)
140148
}
141149

142-
if let delegate = delegate, let address = chatroom.partner?.address, let message = delegate.getPreservedMessageFor(address: address, thenRemoveIt: true) {
150+
if let delegate = delegate, let address = chatroom?.partner?.address, let message = delegate.getPreservedMessageFor(address: address, thenRemoveIt: true) {
143151
messageInputBar.inputTextView.text = message
144152
setEstimatedFee(AdamantFeeCalculator.estimatedFeeFor(message: AdamantMessage.text(message)))
145153
}
@@ -187,7 +195,6 @@ extension ChatViewController {
187195
feeIsVisible = true
188196
feeTimer = Timer.scheduledTimer(withTimeInterval: 3.0, repeats: false) { [weak self] _ in
189197
DispatchQueue.main.async {
190-
self?.feeLabel?.isHidden = false
191198
UIView.animate(withDuration: 0.3, animations: {
192199
self?.feeLabel?.alpha = 1
193200
})
@@ -204,8 +211,6 @@ extension ChatViewController {
204211

205212
UIView.animate(withDuration: 0.3, animations: {
206213
self.feeLabel?.alpha = 0
207-
}, completion: { _ in
208-
self.feeLabel?.isHidden = true
209214
})
210215

211216
feeTimer = nil

0 commit comments

Comments
 (0)