Skip to content

Commit 86425c5

Browse files
committed
Clean up ahead of PR.
// FREEBIE
1 parent 2c12896 commit 86425c5

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ SPEC CHECKSUMS:
173173
YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f
174174
ZXingObjC: bf15b3814f7a105b6d99f47da2333c93a063650a
175175

176-
PODFILE CHECKSUM: 46024b1782e46d426bee430a0b23d93cf417313b
176+
PODFILE CHECKSUM: 6e9ae23065923999ef15e564be4cfef4b12b54e4
177177

178178
COCOAPODS: 1.0.1

Signal/src/view controllers/CallViewController.swift

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class CallViewController: UIViewController {
169169
var hangUpButton: UIButton!
170170
var muteButton: UIButton!
171171
var speakerPhoneButton: UIButton!
172-
// Which call states does this apply to?
172+
// TODO: Which call states does this apply to?
173173
var textMessageButton: UIButton!
174174
var videoButton: UIButton!
175175

@@ -247,56 +247,59 @@ class CallViewController: UIViewController {
247247
self.view.addSubview(contactAvatarView)
248248

249249
// Ongoing call controls
250+
let buttonSize = ScaleFromIPhone5To7Plus(70, 90)
250251
textMessageButton = createButton(imageName:"logoSignal",
251252
action:#selector(didPressTextMessage),
252-
buttonSize:smallButtonSize())
253+
buttonSize:buttonSize)
253254
muteButton = createButton(imageName:"mute-inactive",
254255
action:#selector(didPressMute),
255-
buttonSize:smallButtonSize())
256+
buttonSize:buttonSize)
256257
speakerPhoneButton = createButton(imageName:"speaker-inactive",
257258
action:#selector(didPressSpeakerphone),
258-
buttonSize:smallButtonSize())
259+
buttonSize:buttonSize)
259260
videoButton = createButton(imageName:"video-active",
260261
action:#selector(didPressVideo),
261-
buttonSize:smallButtonSize())
262+
buttonSize:buttonSize)
262263
hangUpButton = createButton(imageName:"endcall",
263264
action:#selector(didPressHangup),
264-
buttonSize:largeButtonSize())
265+
buttonSize:buttonSize)
265266

267+
// A container for 3 rows of ongoing call controls.
266268
ongoingCallView = UIView()
267269
self.view.addSubview(ongoingCallView)
268-
269-
let ongoingCallRow1 = rowWithSubviews(subviews:[textMessageButton, videoButton])
270-
let ongoingCallRow2 = rowWithSubviews(subviews:[muteButton, speakerPhoneButton,])
271-
let ongoingCallRow3 = rowWithSubviews(subviews:[hangUpButton])
272-
ongoingCallRow1.autoSetDimension(.height, toSize:smallButtonSize())
273-
ongoingCallRow2.autoSetDimension(.height, toSize:smallButtonSize())
274-
ongoingCallRow3.autoSetDimension(.height, toSize:largeButtonSize())
275-
ongoingCallView.addSubview(ongoingCallRow1)
276-
ongoingCallView.addSubview(ongoingCallRow2)
277-
ongoingCallView.addSubview(ongoingCallRow3)
278-
270+
let ongoingCallRows = [
271+
rowWithSubviews(subviews:[textMessageButton, videoButton],
272+
fixedHeight:buttonSize),
273+
rowWithSubviews(subviews:[muteButton, speakerPhoneButton,],
274+
fixedHeight:buttonSize),
275+
rowWithSubviews(subviews:[hangUpButton],
276+
fixedHeight:buttonSize),
277+
]
279278
let ongoingCallRowSpacing = ScaleFromIPhone5To7Plus(20, 25)
280-
ongoingCallRow2.autoPinEdge(.top, to:.bottom, of:ongoingCallRow1, withOffset:ongoingCallRowSpacing)
281-
ongoingCallRow3.autoPinEdge(.top, to:.bottom, of:ongoingCallRow2, withOffset:ongoingCallRowSpacing)
282-
ongoingCallRow1.autoPinWidthToSuperview()
283-
ongoingCallRow2.autoPinWidthToSuperview()
284-
ongoingCallRow3.autoPinWidthToSuperview()
279+
var lastRow : UIView?
280+
for row in ongoingCallRows {
281+
ongoingCallView.addSubview(row)
282+
row.autoPinWidthToSuperview()
283+
if lastRow != nil {
284+
row.autoPinEdge(.top, to:.bottom, of:lastRow!, withOffset:ongoingCallRowSpacing)
285+
}
286+
lastRow = row
287+
}
285288

286289
ongoingCallView.setContentHuggingVerticalHigh()
287-
ongoingCallView.subviews.first!.autoPinEdge(toSuperviewEdge:.top)
288-
ongoingCallView.subviews.last!.autoPinEdge(toSuperviewEdge:.bottom)
290+
ongoingCallRows.first!.autoPinEdge(toSuperviewEdge:.top)
291+
ongoingCallRows.last!.autoPinEdge(toSuperviewEdge:.bottom)
289292

290293
// Incoming call controls
291294
acceptIncomingButton = createButton(imageName:"call",
292295
action:#selector(didPressAnswerCall),
293-
buttonSize:largeButtonSize())
296+
buttonSize:buttonSize)
294297
declineIncomingButton = createButton(imageName:"endcall",
295298
action:#selector(didPressDeclineCall),
296-
buttonSize:largeButtonSize())
299+
buttonSize:buttonSize)
297300

298-
incomingCallControlsRow = rowWithSubviews(subviews:[acceptIncomingButton, declineIncomingButton])
299-
incomingCallControlsRow.autoSetDimension(.height, toSize:largeButtonSize())
301+
incomingCallControlsRow = rowWithSubviews(subviews:[acceptIncomingButton, declineIncomingButton],
302+
fixedHeight:buttonSize)
300303
self.view.addSubview(incomingCallControlsRow)
301304
}
302305

@@ -312,20 +315,13 @@ class CallViewController: UIViewController {
312315
return button
313316
}
314317

315-
func smallButtonSize() -> CGFloat {
316-
return ScaleFromIPhone5To7Plus(70, 90)
317-
}
318-
319-
func largeButtonSize() -> CGFloat {
320-
return ScaleFromIPhone5To7Plus(70, 90)
321-
}
322-
323318
// Creates a row view that evenly spaces its subviews horizontally.
324319
// If there is only a single subview, it is centered.
325-
func rowWithSubviews(subviews : Array<UIButton>) -> UIView {
320+
func rowWithSubviews(subviews : Array<UIButton>, fixedHeight : CGFloat) -> UIView {
326321
let row = UIView()
327322
row.setContentHuggingVerticalHigh()
328-
323+
row.autoSetDimension(.height, toSize:fixedHeight)
324+
329325
if subviews.count > 1 {
330326
var lastSubview : UIView?
331327
var lastSpacer : UIView?
@@ -489,6 +485,7 @@ class CallViewController: UIViewController {
489485
}
490486

491487
func incomingCallControls() -> [UIView] {
488+
// TODO: Should this include textMessageButton?
492489
return [ acceptIncomingButton, declineIncomingButton, ]
493490
}
494491

0 commit comments

Comments
 (0)