Skip to content

Commit

Permalink
Fix total price style
Browse files Browse the repository at this point in the history
  • Loading branch information
turekj committed Jan 31, 2019
1 parent 9449bf3 commit d82304d
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github "Raizlabs/Anchorage" ~> 4.3
github "hyperoslo/Hue" ~> 4.0
github "Raizlabs/BonMot" ~> 5.3

1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
github "Quick/Nimble" "v7.3.3"
github "Quick/Quick" "v1.3.4"
github "Raizlabs/Anchorage" "4.3"
github "Raizlabs/BonMot" "5.3"
github "hyperoslo/Hue" "4.0.0"
github "pointfreeco/swift-snapshot-testing" "1.1.0"
18 changes: 18 additions & 0 deletions VinylShop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
3267255DA6CB95D2D25F1451 /* Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3267270A4EB69958133B7A24 /* Styles.swift */; };
326725B60D2A34323456CEC7 /* AppDelegateSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32672597C6B12FBFFD07B57B /* AppDelegateSpec.swift */; };
326725D5281E8E88A54608BA /* ShoppingBoxController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326724E88E5186E5360C53BB /* ShoppingBoxController.swift */; };
3267267ACE9FF34308BD5EF2 /* UIFont+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3267296229946757EEAEABDE /* UIFont+Convenience.swift */; };
32672681BBCAEB446548E977 /* ShoppingBoxPriceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32672549DA59C2630442ED22 /* ShoppingBoxPriceView.swift */; };
326726D75CFC5FAAEF190469 /* UIStackView+ReplaceSubviews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32672FFA0D644C14D2F38740 /* UIStackView+ReplaceSubviews.swift */; };
3267272E7AFC942CF7674E1E /* UIBezierPath+LineInRectangle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326726D9597284D35435DCDB /* UIBezierPath+LineInRectangle.swift */; };
Expand Down Expand Up @@ -53,6 +54,7 @@
8C2243CF2202125600C3470B /* Nunito-ExtraBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8C2243C12202125600C3470B /* Nunito-ExtraBold.ttf */; };
8C2243D02202125600C3470B /* Nunito-SemiBoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8C2243C22202125600C3470B /* Nunito-SemiBoldItalic.ttf */; };
8C2243D2220213A700C3470B /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C2243D1220213A700C3470B /* Font.swift */; };
8CD3274222030922009711DA /* BonMot.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CD3274122030922009711DA /* BonMot.framework */; };
8CFA76D52201DC8B00E4D81D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CFA76D42201DC8B00E4D81D /* ViewController.swift */; };
8CFA76DA2201DC8C00E4D81D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8CFA76D92201DC8C00E4D81D /* Assets.xcassets */; };
8CFA76DD2201DC8C00E4D81D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8CFA76DB2201DC8C00E4D81D /* LaunchScreen.storyboard */; };
Expand Down Expand Up @@ -109,6 +111,7 @@
32672758F5AEE9FEC5CAF5F7 /* ShoppingBoxItemsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShoppingBoxItemsView.swift; sourceTree = "<group>"; };
326728130821FC372F765BF6 /* ShoppingBoxControllerSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShoppingBoxControllerSpec.swift; sourceTree = "<group>"; };
3267294512FB162C8DF3AE65 /* UIViewController+ChildrenSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+ChildrenSpec.swift"; sourceTree = "<group>"; };
3267296229946757EEAEABDE /* UIFont+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIFont+Convenience.swift"; sourceTree = "<group>"; };
32672AD7C23E69A499813550 /* ShoppingBoxStyles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShoppingBoxStyles.swift; sourceTree = "<group>"; };
32672AE680239A70B031D0F0 /* RoundedCorner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoundedCorner.swift; sourceTree = "<group>"; };
32672B3020CF2515472B6E5B /* ShoppingBoxView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShoppingBoxView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -138,6 +141,7 @@
8C2243C12202125600C3470B /* Nunito-ExtraBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Nunito-ExtraBold.ttf"; sourceTree = "<group>"; };
8C2243C22202125600C3470B /* Nunito-SemiBoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Nunito-SemiBoldItalic.ttf"; sourceTree = "<group>"; };
8C2243D1220213A700C3470B /* Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
8CD3274122030922009711DA /* BonMot.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BonMot.framework; path = Carthage/Build/iOS/BonMot.framework; sourceTree = "<group>"; };
8CFA76CF2201DC8B00E4D81D /* VinylShop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VinylShop.app; sourceTree = BUILT_PRODUCTS_DIR; };
8CFA76D42201DC8B00E4D81D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
8CFA76D92201DC8C00E4D81D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand All @@ -158,6 +162,7 @@
buildActionMask = 2147483647;
files = (
8CFA77012201EDAF00E4D81D /* Anchorage.framework in Frameworks */,
8CD3274222030922009711DA /* BonMot.framework in Frameworks */,
8CFA77082201F99A00E4D81D /* Hue.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -271,6 +276,7 @@
326723C7D2E90843B713781C /* UIImage */,
3267201EAC7DCE15C25904CA /* UIStackView */,
326725A05B7FFD9EC6057D2F /* UIViewController */,
32672B4F7718AF9689E3763A /* UIFont */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -324,6 +330,14 @@
path = Styles;
sourceTree = "<group>";
};
32672B4F7718AF9689E3763A /* UIFont */ = {
isa = PBXGroup;
children = (
3267296229946757EEAEABDE /* UIFont+Convenience.swift */,
);
path = UIFont;
sourceTree = "<group>";
};
32672CFAAE3B1ACA9DE1C614 /* Extensions */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -454,6 +468,7 @@
8CFA76F22201E65100E4D81D /* Frameworks */ = {
isa = PBXGroup;
children = (
8CD3274122030922009711DA /* BonMot.framework */,
8CFA77072201F99A00E4D81D /* Hue.framework */,
8CFA77002201EDAF00E4D81D /* Anchorage.framework */,
8CFA76FD2201EC4900E4D81D /* SnapshotTesting.framework */,
Expand Down Expand Up @@ -586,13 +601,15 @@
inputPaths = (
"$(SRCROOT)/Carthage/Build/iOS/Anchorage.framework",
"$(SRCROOT)/Carthage/Build/iOS/Hue.framework",
"$(SRCROOT)/Carthage/Build/iOS/BonMot.framework",
);
name = "Carthage Copy Frameworks";
outputFileListPaths = (
);
outputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Anchorage.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Hue.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/BonMot.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -647,6 +664,7 @@
3267248AF1A53F1BD2544336 /* UIImage+Color.swift in Sources */,
32672848E415A5994F8B13B5 /* ShoppingBoxStyles.swift in Sources */,
32672F749470BDAF17C3EEA4 /* UIViewController+Embed.swift in Sources */,
3267267ACE9FF34308BD5EF2 /* UIFont+Convenience.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
13 changes: 13 additions & 0 deletions VinylShop/Extensions/UIFont/UIFont+Convenience.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import UIKit

extension UIFont {

static func from(_ font: Font, ofSize size: CGFloat) -> UIFont {
guard let uiFont = UIFont(name: font.name, size: size) else {
fatalError("Could not load the \(font.name) font")
}

return uiFont
}

}
7 changes: 7 additions & 0 deletions VinylShop/Styles/Styles.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BonMot
import Hue
import UIKit

Expand Down Expand Up @@ -35,6 +36,12 @@ func text(_ text: String) -> (UILabel) -> Void {
}
}

func text(_ text: String, style: StringStyle) -> (UILabel) -> Void {
return { label in
label.attributedText = text.styled(with: style)
}
}

func bordered(width: CGFloat, color: Color, alpha: CGFloat = 1.0) -> (UIView) -> Void {
return { view in
view.layer.borderWidth = width
Expand Down
19 changes: 19 additions & 0 deletions VinylShop/UI/Screens/ShoppingBox/Styles/ShoppingBoxStyles.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BonMot
import UIKit

func checkoutButtonStyle() -> (UIButton) -> Void {
Expand All @@ -9,3 +10,21 @@ func checkoutButtonStyle() -> (UIButton) -> Void {
<> insetContent(left: 20, right: 25)
<> insetTitle(left: 16)
}

extension StringStyle {

static var totalPriceStyle: StringStyle {
let currencyStyle = StringStyle(.font(.from(.nunito(.bold), ofSize: 20)), .baselineOffset(4))
let priceStyle = StringStyle(.font(.from(.nunito(.bold), ofSize: 28)))

return StringStyle(
.color(Color.whiteFFFFFF.ui()),
.font(.from(.nunito(.bold), ofSize: 10)),
.xmlRules([
.style("currency", currencyStyle),
.style("price", priceStyle)
])
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class ShoppingBoxFooterView: UIView {
<> font(.nunito(.semibold), size: 14, color: .whiteFFFFFF)

let priceLabel = UILabel(frame: .zero)
|> text("$30")
<> font(.nunito(.bold), size: 28, color: .whiteFFFFFF) // FIXME: $ should have a different font
|> text("<currency>$</currency> <price>30</price>", style: .totalPriceStyle)

let checkoutButton = UIButton(frame: .zero)
|> checkoutButtonStyle()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d82304d

Please sign in to comment.