Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-ios
Commits
819af881
Unverified
Commit
819af881
authored
Nov 11, 2017
by
Zach Knox
Browse files
proper open/closed label padding
Also, @IBDesignable is super cool
parent
5e8c4e38
Changes
5
Hide whitespace changes
Inline
Side-by-side
WhatsOpen/WhatsOpen.xcodeproj/project.pbxproj
View file @
819af881
...
...
@@ -19,6 +19,7 @@
9270A4DD1EC0010300DFBDA3
/* Filters.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9270A4DC1EC0010300DFBDA3
/* Filters.swift */
;
};
927C80DA1EB02566009079AD
/* SettingsTableViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
927C80D91EB02566009079AD
/* SettingsTableViewController.swift */
;
};
927C80DC1EB18B89009079AD
/* FiltersTableViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
927C80DB1EB18B89009079AD
/* FiltersTableViewController.swift */
;
};
92EA81971FB7D1B500B1F6E3
/* PaddedUILabel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
92EA81961FB7D1B500B1F6E3
/* PaddedUILabel.swift */
;
};
CD3C97491DC18AB300A84434
/* SRCTNetworkController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD3C97481DC18AB300A84434
/* SRCTNetworkController.swift */
;
};
CD466DD21DC12E1200E44DF5
/* MainTableViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD466DD11DC12E1200E44DF5
/* MainTableViewController.swift */
;
};
CD763A7A1DE24EF100ADFD6B
/* examplejson.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD763A791DE24EF100ADFD6B
/* examplejson.swift */
;
};
...
...
@@ -56,6 +57,7 @@
927A8466141434969CE74044
/* Pods_WhatsOpen.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Pods_WhatsOpen.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
927C80D91EB02566009079AD
/* SettingsTableViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SettingsTableViewController.swift
;
sourceTree
=
"<group>"
;
};
927C80DB1EB18B89009079AD
/* FiltersTableViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FiltersTableViewController.swift
;
sourceTree
=
"<group>"
;
};
92EA81961FB7D1B500B1F6E3
/* PaddedUILabel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
name
=
PaddedUILabel.swift
;
path
=
WhatsOpen/PaddedUILabel.swift
;
sourceTree
=
SOURCE_ROOT
;
};
CD3C97481DC18AB300A84434
/* SRCTNetworkController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SRCTNetworkController.swift
;
sourceTree
=
"<group>"
;
};
CD466DD11DC12E1200E44DF5
/* MainTableViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MainTableViewController.swift
;
sourceTree
=
"<group>"
;
};
CD763A791DE24EF100ADFD6B
/* examplejson.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
name
=
examplejson.swift
;
path
=
"Object Model/examplejson.swift"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -150,6 +152,7 @@
CD763A7D1DE253B900ADFD6B
/* SRCTUtilities.swift */
,
CD763A7B1DE251C400ADFD6B
/* SRCTSimpleTableViewCell.swift */
,
924840F71EA915F200DBFF4E
/* FacilityCollectionViewCell.swift */
,
92EA81961FB7D1B500B1F6E3
/* PaddedUILabel.swift */
,
CD81F5201DC0334600009FBD
/* Main.storyboard */
,
920D17961F6C5CD200D63295
/* Views */
,
CD81F5231DC0334600009FBD
/* Assets.xcassets */
,
...
...
@@ -359,6 +362,7 @@
92182EC01E95BD2C00192ABA
/* FacilitiesListViewController.swift in Sources */
,
CD763A7A1DE24EF100ADFD6B
/* examplejson.swift in Sources */
,
9265F3A31F2C0B1500A54A21
/* AboutScreenViewController.swift in Sources */
,
92EA81971FB7D1B500B1F6E3
/* PaddedUILabel.swift in Sources */
,
CD466DD21DC12E1200E44DF5
/* MainTableViewController.swift in Sources */
,
924840F81EA915F200DBFF4E
/* FacilityCollectionViewCell.swift in Sources */
,
9265F3A11F2969E500A54A21
/* SettingTableViewCell.swift in Sources */
,
...
...
WhatsOpen/WhatsOpen/Base.lproj/Main.storyboard
View file @
819af881
...
...
@@ -190,16 +190,24 @@
<color
key=
"textColor"
white=
"1"
alpha=
"1"
colorSpace=
"calibratedWhite"
/>
<nil
key=
"highlightedColor"
/>
</label>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Open"
textAlignment=
"center"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"DEx-BH-Fun"
>
<rect
key=
"frame"
x=
"4"
y=
"97"
width=
"
83
"
height=
"28"
/>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Open"
textAlignment=
"center"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"DEx-BH-Fun"
customClass=
"PaddedUILabel"
customModule=
"WhatsOpen"
customModuleProvider=
"target"
>
<rect
key=
"frame"
x=
"4"
y=
"97"
width=
"
72
"
height=
"28"
/>
<color
key=
"backgroundColor"
white=
"0.0"
alpha=
"1"
colorSpace=
"calibratedWhite"
/>
<constraints>
<constraint
firstAttribute=
"width"
constant=
"
83
"
id=
"IAg-Ei-cjz"
/>
<constraint
firstAttribute=
"width"
relation=
"greaterThanOrEqual"
constant=
"
72
"
id=
"IAg-Ei-cjz"
/>
<constraint
firstAttribute=
"height"
constant=
"28"
id=
"asd-vB-57f"
/>
</constraints>
<fontDescription
key=
"fontDescription"
type=
"system"
weight=
"semibold"
pointSize=
"18"
/>
<color
key=
"textColor"
white=
"1"
alpha=
"1"
colorSpace=
"calibratedWhite"
/>
<nil
key=
"highlightedColor"
/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute
type=
"number"
keyPath=
"leftTextInset"
>
<real
key=
"value"
value=
"5"
/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute
type=
"number"
keyPath=
"rightTextInset"
>
<real
key=
"value"
value=
"5"
/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
misplaced=
"YES"
text=
"RESTAURANT"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"uhu-6U-8Tx"
>
<rect
key=
"frame"
x=
"4"
y=
"8"
width=
"291"
height=
"20"
/>
...
...
WhatsOpen/WhatsOpen/FacilityCollectionViewCell.swift
View file @
819af881
...
...
@@ -12,7 +12,7 @@ import QuartzCore
class
FacilityCollectionViewCell
:
UICollectionViewCell
{
@IBOutlet
var
nameLabel
:
UILabel
!
@IBOutlet
var
timeDescriptionLabel
:
UILabel
!
@IBOutlet
var
openClosedLabel
:
UILabel
!
@IBOutlet
var
openClosedLabel
:
Padded
UILabel
!
@IBOutlet
var
categoryLabel
:
UILabel
!
var
facility
:
Facility
!
internal
let
tapRecognizer
:
UITapGestureRecognizer
=
UITapGestureRecognizer
()
...
...
WhatsOpen/WhatsOpen/PaddedUILabel.swift
0 → 100644
View file @
819af881
//
// PaddedUILabel.swift
// WhatsOpen
//
// Created by Zach Knox on 11/11/17.
// Copyright © 2017 SRCT. All rights reserved.
//
import
UIKit
// Based on this
// https://stackoverflow.com/questions/21167226/resizing-a-uilabel-to-accommodate-insets/21267507#21267507
// The entire reason for this subclass of UILabel is for the openClosedLabel in FacilityCollectionViewCell
class
PaddedUILabel
:
UILabel
{
var
textInsets
=
UIEdgeInsets
.
zero
{
didSet
{
invalidateIntrinsicContentSize
()
}
}
override
func
textRect
(
forBounds
bounds
:
CGRect
,
limitedToNumberOfLines
numberOfLines
:
Int
)
->
CGRect
{
let
insetRect
=
UIEdgeInsetsInsetRect
(
bounds
,
textInsets
)
let
textRect
=
super
.
textRect
(
forBounds
:
insetRect
,
limitedToNumberOfLines
:
numberOfLines
)
let
invertedInsets
=
UIEdgeInsets
(
top
:
-
textInsets
.
top
,
left
:
-
textInsets
.
left
,
bottom
:
-
textInsets
.
bottom
,
right
:
-
textInsets
.
right
)
return
UIEdgeInsetsInsetRect
(
textRect
,
invertedInsets
)
}
override
func
drawText
(
in
rect
:
CGRect
)
{
super
.
drawText
(
in
:
UIEdgeInsetsInsetRect
(
rect
,
textInsets
))
}
}
@IBDesignable
extension
PaddedUILabel
{
// currently UIEdgeInsets is no supported IBDesignable type,
// so we have to fan it out here:
@IBInspectable
var
leftTextInset
:
CGFloat
{
set
{
textInsets
.
left
=
newValue
}
get
{
return
textInsets
.
left
}
}
@IBInspectable
var
rightTextInset
:
CGFloat
{
set
{
textInsets
.
right
=
newValue
}
get
{
return
textInsets
.
right
}
}
}
WhatsOpen/WhatsOpen/Views/FacilitiesListViewController.swift
View file @
819af881
...
...
@@ -199,7 +199,8 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
cell
.
categoryLabel
.
text
=
facility
.
category
?
.
categoryName
.
uppercased
()
let
open
=
Utilities
.
isOpen
(
facility
:
facility
)
cell
.
openClosedLabel
.
text
=
Utilities
.
openOrClosedUntil
(
facility
)
let
openClosedText
=
Utilities
.
openOrClosedUntil
(
facility
)
cell
.
openClosedLabel
.
text
=
openClosedText
!
//my god what a hack
if
(
open
==
true
)
{
//cell.openClosedLabel.text = "Open"
cell
.
openClosedLabel
.
textColor
=
UIColor
.
black
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment