Skip to content

Commit fdd82fe

Browse files
author
Daniel Dahan
committed
Merge branch 'development'
2 parents 9b014ad + adbf333 commit fdd82fe

File tree

4 files changed

+107
-32
lines changed

4 files changed

+107
-32
lines changed

MK.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'MK'
3-
s.version = '1.10.0'
3+
s.version = '1.11.0'
44
s.license = { :type => "AGPLv3+", :file => "LICENSE" }
55
s.summary = 'A Material Design Framework In Swift'
66
s.homepage = 'http://materialkit.io'

Source/BasicCardView.swift

+47-14
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,38 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
3030
internal lazy var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
3131

3232
/**
33-
:name: verticalSpace
33+
:name: verticalTitleLabelSpace
3434
*/
35-
public var verticalSpace: CGFloat = MaterialTheme.verticalSpace
35+
public var verticalTitleLabelSpace: CGFloat = MaterialTheme.verticalSpace
3636

3737
/**
38-
:name: horizontalSpace
38+
:name: horizontalTitleLabelSpace
39+
*/
40+
public var horizontalTitleLabelSpace: CGFloat = MaterialTheme.horizontalSpace
41+
42+
/**
43+
:name: verticalDetailLabelSpace
44+
*/
45+
public var verticalDetailLabelSpace: CGFloat = MaterialTheme.verticalSpace
46+
47+
/**
48+
:name: horizontalDetailLabelSpace
49+
*/
50+
public var horizontalDetailLabelSpace: CGFloat = MaterialTheme.horizontalSpace
51+
52+
/**
53+
:name: verticalButtonSpace
54+
*/
55+
public var verticalButtonSpace: CGFloat = MaterialTheme.verticalSpace
56+
57+
/**
58+
:name: horizontalButtonSpace
59+
*/
60+
public var horizontalButtonSpace: CGFloat = MaterialTheme.horizontalSpace
61+
62+
/**
63+
:name: horizontalButtonSpace
3964
*/
40-
public var horizontalSpace: CGFloat = MaterialTheme.horizontalSpace
4165

4266
/**
4367
:name: titleLabelContainer
@@ -237,31 +261,40 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
237261

238262
// title
239263
if nil != titleLabelContainer && nil != titleLabel {
264+
// clear for updated constraints
265+
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints())
266+
240267
// container
241268
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
242269
verticalFormat += "[titleLabelContainer]"
243270
views["titleLabelContainer"] = titleLabelContainer!
244271

245272
// common text
246273
Layout.height(titleLabelContainer!, child: titleLabel!, height: 1.5 * titleLabel!.font.pointSize)
247-
Layout.expandToParentVerticallyWithPad(titleLabelContainer!, child: titleLabel!, top: verticalSpace, bottom: verticalSpace)
248-
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: horizontalSpace, right: horizontalSpace)
274+
Layout.expandToParentVerticallyWithPad(titleLabelContainer!, child: titleLabel!, top: verticalTitleLabelSpace, bottom: verticalTitleLabelSpace)
275+
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: horizontalTitleLabelSpace, right: horizontalTitleLabelSpace)
249276
}
250277

251278
// detail
252279
if nil != detailLabelContainer && nil != detailLabel {
280+
// clear for updated constraints
281+
detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints())
282+
253283
// container
254284
layoutConstraints += Layout.constraint("H:|[detailLabelContainer]|", options: nil, metrics: nil, views: ["detailLabelContainer": detailLabelContainer!])
255285
verticalFormat += "[detailLabelContainer]"
256286
views["detailLabelContainer"] = detailLabelContainer!
257287

258288
// text
259-
Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: horizontalSpace, right: horizontalSpace)
260-
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
289+
Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: horizontalDetailLabelSpace, right: horizontalDetailLabelSpace)
290+
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalDetailLabelSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalDetailLabelSpace)-|", options: nil, metrics: ["verticalDetailLabelSpace": verticalDetailLabelSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
261291
}
262292

263293
// buttons
264294
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
295+
// clear for updated constraints
296+
buttonsContainer!.removeConstraints(buttonsContainer!.constraints())
297+
265298
// divider
266299
if nil != divider {
267300
layoutConstraints += Layout.constraint("H:|[divider]|", options: nil, metrics: nil, views: ["divider": divider!])
@@ -282,10 +315,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
282315
let button: MaterialButton = leftButtons![i]
283316
buttonsContainer!.addSubview(button)
284317
buttonViews["button\(i)"] = button
285-
horizontalFormat += "-(horizontalSpace)-[button\(i)]"
286-
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
318+
horizontalFormat += "-(horizontalButtonSpace)-[button\(i)]"
319+
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalButtonSpace, bottom: verticalButtonSpace)
287320
}
288-
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
321+
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalButtonSpace": horizontalButtonSpace], views: buttonViews))
289322
}
290323

291324
// rightButtons
@@ -296,10 +329,10 @@ public class BasicCardView : MaterialCardView, Comparable, Equatable {
296329
let button: MaterialButton = rightButtons![i]
297330
buttonsContainer!.addSubview(button)
298331
buttonViews["button\(i)"] = button
299-
horizontalFormat += "[button\(i)]-(horizontalSpace)-"
300-
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
332+
horizontalFormat += "[button\(i)]-(horizontalButtonSpace)-"
333+
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalButtonSpace, bottom: verticalButtonSpace)
301334
}
302-
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
335+
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalButtonSpace": horizontalButtonSpace], views: buttonViews))
303336
}
304337
}
305338

Source/ImageCardView.swift

+58-16
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,44 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
3030
internal lazy var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
3131

3232
/**
33-
:name: verticalSpace
33+
:name: verticalImageViewSpace
3434
*/
35-
public var verticalSpace: CGFloat = MaterialTheme.verticalSpace
35+
public var verticalImageViewSpace: CGFloat = 0
3636

3737
/**
38-
:name: horizontalSpace
38+
:name: horizontalImageViewSpace
3939
*/
40-
public var horizontalSpace: CGFloat = MaterialTheme.horizontalSpace
40+
public var horizontalImageViewSpace: CGFloat = 0
41+
42+
/**
43+
:name: verticalTitleLabelSpace
44+
*/
45+
public var verticalTitleLabelSpace: CGFloat = MaterialTheme.verticalSpace
46+
47+
/**
48+
:name: horizontalTitleLabelSpace
49+
*/
50+
public var horizontalTitleLabelSpace: CGFloat = MaterialTheme.horizontalSpace
51+
52+
/**
53+
:name: verticalDetailLabelSpace
54+
*/
55+
public var verticalDetailLabelSpace: CGFloat = MaterialTheme.verticalSpace
56+
57+
/**
58+
:name: horizontalDetailLabelSpace
59+
*/
60+
public var horizontalDetailLabelSpace: CGFloat = MaterialTheme.horizontalSpace
61+
62+
/**
63+
:name: verticalButtonSpace
64+
*/
65+
public var verticalButtonSpace: CGFloat = MaterialTheme.verticalSpace
66+
67+
/**
68+
:name: horizontalButtonSpace
69+
*/
70+
public var horizontalButtonSpace: CGFloat = MaterialTheme.horizontalSpace
4171

4272
/**
4373
:name: shadow
@@ -288,18 +318,24 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
288318

289319
// image
290320
if nil != imageViewContainer && nil != imageView {
321+
// clear for updated constraints
322+
imageViewContainer!.removeConstraints(imageViewContainer!.constraints())
323+
291324
// container
292325
layoutConstraints += Layout.constraint("H:|[imageViewContainer]|", options: nil, metrics: nil, views: ["imageViewContainer": imageViewContainer!])
293326
verticalFormat += "[imageViewContainer]"
294327
views["imageViewContainer"] = imageViewContainer!
295328

296329
// text
297-
imageViewContainer!.addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: ["imageView": imageView!]))
298-
imageViewContainer!.addConstraints(Layout.constraint("V:|[imageView(maximumImageViewHeight)]|", options: nil, metrics: ["maximumImageViewHeight": maximumImageViewHeight], views: ["imageView": imageView!]))
330+
imageViewContainer!.addConstraints(Layout.constraint("H:|-(horizontalImageViewSpace)-[imageView]-(horizontalImageViewSpace)-|", options: nil, metrics: ["horizontalImageViewSpace": horizontalImageViewSpace], views: ["imageView": imageView!]))
331+
imageViewContainer!.addConstraints(Layout.constraint("V:|-(verticalImageViewSpace)-[imageView(maximumImageViewHeight)]-(verticalImageViewSpace)-|", options: nil, metrics: ["verticalImageViewSpace": verticalImageViewSpace, "maximumImageViewHeight": maximumImageViewHeight], views: ["imageView": imageView!]))
299332
}
300333

301334
// title
302335
if nil != titleLabelContainer && nil != titleLabel {
336+
// clear for updated constraints
337+
titleLabelContainer!.removeConstraints(titleLabelContainer!.constraints())
338+
303339
if nil == imageView {
304340
// container
305341
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
@@ -313,24 +349,30 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
313349

314350
// common text
315351
Layout.height(titleLabelContainer!, child: titleLabel!, height: 1.5 * titleLabel!.font.pointSize)
316-
Layout.expandToParentVerticallyWithPad(titleLabelContainer!, child: titleLabel!, top: verticalSpace, bottom: verticalSpace)
317-
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: horizontalSpace, right: horizontalSpace)
352+
Layout.expandToParentVerticallyWithPad(titleLabelContainer!, child: titleLabel!, top: verticalTitleLabelSpace, bottom: verticalTitleLabelSpace)
353+
Layout.expandToParentHorizontallyWithPad(titleLabelContainer!, child: titleLabel!, left: horizontalTitleLabelSpace, right: horizontalTitleLabelSpace)
318354
}
319355

320356
// detail
321357
if nil != detailLabelContainer && nil != detailLabel {
358+
// clear for updated constraints
359+
detailLabelContainer!.removeConstraints(detailLabelContainer!.constraints())
360+
322361
// container
323362
layoutConstraints += Layout.constraint("H:|[detailLabelContainer]|", options: nil, metrics: nil, views: ["detailLabelContainer": detailLabelContainer!])
324363
verticalFormat += "[detailLabelContainer]"
325364
views["detailLabelContainer"] = detailLabelContainer!
326365

327366
// text
328-
Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: horizontalSpace, right: horizontalSpace)
329-
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
367+
Layout.expandToParentHorizontallyWithPad(detailLabelContainer!, child: detailLabel!, left: horizontalDetailLabelSpace, right: horizontalDetailLabelSpace)
368+
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalDetailLabelSpace)-[detailLabel(<=maximumDetailLabelHeight)]-(verticalDetailLabelSpace)-|", options: nil, metrics: ["verticalDetailLabelSpace": verticalDetailLabelSpace, "maximumDetailLabelHeight": maximumDetailLabelHeight], views: ["detailLabel": detailLabel!]))
330369
}
331370

332371
// buttons
333372
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
373+
// clear for updated constraints
374+
buttonsContainer!.removeConstraints(buttonsContainer!.constraints())
375+
334376
// divider
335377
if nil != divider {
336378
layoutConstraints += Layout.constraint("H:|[divider]|", options: nil, metrics: nil, views: ["divider": divider!])
@@ -351,10 +393,10 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
351393
let button: MaterialButton = leftButtons![i]
352394
buttonsContainer!.addSubview(button)
353395
buttonViews["button\(i)"] = button
354-
horizontalFormat += "-(horizontalSpace)-[button\(i)]"
355-
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
396+
horizontalFormat += "-(horizontalButtonSpace)-[button\(i)]"
397+
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalButtonSpace, bottom: verticalButtonSpace)
356398
}
357-
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
399+
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["horizontalButtonSpace": horizontalButtonSpace], views: buttonViews))
358400
}
359401

360402
// rightButtons
@@ -365,10 +407,10 @@ public class ImageCardView : MaterialCardView, Comparable, Equatable {
365407
let button: MaterialButton = rightButtons![i]
366408
buttonsContainer!.addSubview(button)
367409
buttonViews["button\(i)"] = button
368-
horizontalFormat += "[button\(i)]-(horizontalSpace)-"
369-
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
410+
horizontalFormat += "[button\(i)]-(horizontalButtonSpace)-"
411+
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalButtonSpace, bottom: verticalButtonSpace)
370412
}
371-
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalSpace": horizontalSpace], views: buttonViews))
413+
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["horizontalButtonSpace": horizontalButtonSpace], views: buttonViews))
372414
}
373415
}
374416

Source/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.10.0</string>
18+
<string>1.11.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)