Skip to content

Commit

Permalink
Update examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
gk-brown committed Nov 10, 2018
1 parent d507298 commit aeab310
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 22 deletions.
18 changes: 13 additions & 5 deletions Lima-iOS/Lima-iOS.xcodeproj/project.pbxproj
Expand Up @@ -32,6 +32,8 @@
373EB537218618FA001FE0C9 /* LMSpacer.m in Sources */ = {isa = PBXBuildFile; fileRef = 373EB535218618FA001FE0C9 /* LMSpacer.m */; };
373EB53A21861953001FE0C9 /* UIKit+Lima.m in Sources */ = {isa = PBXBuildFile; fileRef = 373EB53821861953001FE0C9 /* UIKit+Lima.m */; };
373EB53B21861953001FE0C9 /* UIKit+Lima.h in Headers */ = {isa = PBXBuildFile; fileRef = 373EB53921861953001FE0C9 /* UIKit+Lima.h */; settings = {ATTRIBUTES = (Public, ); }; };
374C5836219702A200500E12 /* GreetingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 374C5835219702A200500E12 /* GreetingViewController.swift */; };
374C5838219705CD00500E12 /* world.png in Resources */ = {isa = PBXBuildFile; fileRef = 374C5837219705CD00500E12 /* world.png */; };
374C67C32187B1EA009BF473 /* LMColumnView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 374C67C22187B1EA009BF473 /* LMColumnView.swift */; };
374C67C62187B252009BF473 /* LMRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 374C67C42187B252009BF473 /* LMRootView.m */; };
374C67C72187B252009BF473 /* LMRootView.h in Headers */ = {isa = PBXBuildFile; fileRef = 374C67C52187B252009BF473 /* LMRootView.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -117,6 +119,8 @@
373EB535218618FA001FE0C9 /* LMSpacer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LMSpacer.m; sourceTree = "<group>"; };
373EB53821861953001FE0C9 /* UIKit+Lima.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIKit+Lima.m"; sourceTree = "<group>"; };
373EB53921861953001FE0C9 /* UIKit+Lima.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIKit+Lima.h"; sourceTree = "<group>"; };
374C5835219702A200500E12 /* GreetingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GreetingViewController.swift; sourceTree = "<group>"; };
374C5837219705CD00500E12 /* world.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = world.png; sourceTree = "<group>"; };
374C67C22187B1EA009BF473 /* LMColumnView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LMColumnView.swift; sourceTree = "<group>"; };
374C67C42187B252009BF473 /* LMRootView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LMRootView.m; sourceTree = "<group>"; };
374C67C52187B252009BF473 /* LMRootView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LMRootView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -239,7 +243,7 @@
children = (
37E750252186169900B06374 /* AppDelegate.swift */,
37E750272186169900B06374 /* ViewController.swift */,
378008BB218C55A3009D3C05 /* ControlsViewController.swift */,
374C5835219702A200500E12 /* GreetingViewController.swift */,
375724B3218A80C100E4E9AC /* HorizontalAlignmentViewController.swift */,
375724B4218A80C100E4E9AC /* VerticalAlignmentViewController.swift */,
375724B1218A80C100E4E9AC /* AnchorViewController.swift */,
Expand All @@ -249,13 +253,15 @@
378008BD218C5B96009D3C05 /* ScrollViewController.swift */,
378008BF218C5BA7009D3C05 /* TableViewCellController.swift */,
378008C1218C5BB6009D3C05 /* CollectionViewCellController.swift */,
378008BB218C55A3009D3C05 /* ControlsViewController.swift */,
378008C3218C5BD7009D3C05 /* WebViewController.swift */,
378008C5218C5BDF009D3C05 /* MapViewController.swift */,
378008C7218C5BF1009D3C05 /* AnimationViewController.swift */,
37E7502C2186169900B06374 /* Assets.xcassets */,
37309682218CFA9600F5F329 /* Icons.xcassets */,
37E7502E2186169900B06374 /* LaunchScreen.storyboard */,
37E750312186169900B06374 /* Info.plist */,
374C5837219705CD00500E12 /* world.png */,
379F3A37218DBC56002EA5B0 /* sample.txt */,
379F3A39218DBFA4002EA5B0 /* pharmacies.json */,
379F3A3B218DC6AD002EA5B0 /* daisies.jpg */,
Expand Down Expand Up @@ -377,12 +383,13 @@
buildActionMask = 2147483647;
files = (
37E750302186169900B06374 /* LaunchScreen.storyboard in Resources */,
37E7502D2186169900B06374 /* Assets.xcassets in Resources */,
37FAB1F0219634EF00F3E02A /* PeriodicTableViewController.xib in Resources */,
379F3A3C218DC6AD002EA5B0 /* daisies.jpg in Resources */,
37E7502D2186169900B06374 /* Assets.xcassets in Resources */,
37309683218CFA9600F5F329 /* Icons.xcassets in Resources */,
374C5838219705CD00500E12 /* world.png in Resources */,
379F3A38218DBC56002EA5B0 /* sample.txt in Resources */,
379F3A3A218DBFA4002EA5B0 /* pharmacies.json in Resources */,
37309683218CFA9600F5F329 /* Icons.xcassets in Resources */,
379F3A3C218DC6AD002EA5B0 /* daisies.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -424,14 +431,15 @@
files = (
37E750262186169900B06374 /* AppDelegate.swift in Sources */,
37E750282186169900B06374 /* ViewController.swift in Sources */,
378008BC218C55A3009D3C05 /* ControlsViewController.swift in Sources */,
374C5836219702A200500E12 /* GreetingViewController.swift in Sources */,
375724B7218A80C100E4E9AC /* HorizontalAlignmentViewController.swift in Sources */,
375724B8218A80C100E4E9AC /* VerticalAlignmentViewController.swift in Sources */,
375724B5218A80C100E4E9AC /* AnchorViewController.swift in Sources */,
375724B6218A80C100E4E9AC /* GridViewController.swift in Sources */,
378008BE218C5B96009D3C05 /* ScrollViewController.swift in Sources */,
378008C0218C5BA7009D3C05 /* TableViewCellController.swift in Sources */,
378008C2218C5BB6009D3C05 /* CollectionViewCellController.swift in Sources */,
378008BC218C55A3009D3C05 /* ControlsViewController.swift in Sources */,
378008C4218C5BD7009D3C05 /* WebViewController.swift in Sources */,
378008C6218C5BDF009D3C05 /* MapViewController.swift in Sources */,
37E0B96E2190FB7300AEF092 /* PeriodicTableViewController.swift in Sources */,
Expand Down
30 changes: 30 additions & 0 deletions Lima-iOS/LimaTest/GreetingViewController.swift
@@ -0,0 +1,30 @@
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit
import Lima

class GreetingViewController: UIViewController {
override func loadView() {
let columnView = LMColumnView(
UIImageView(image: UIImage(named: "world.png"), contentMode: .scaleAspectFit),
UILabel(text: "Hello, World!", textAlignment: .center)
)

view = LMScrollView(isFitToWidth: true,
backgroundColor: UIColor.white,
columnView)
}
}

23 changes: 12 additions & 11 deletions Lima-iOS/LimaTest/ViewController.swift
Expand Up @@ -17,9 +17,7 @@ import Lima

class ViewController: UITableViewController {
enum Example: Int, CaseIterable {
#if os(iOS)
case controls
#endif
case greeting
case horizontalAlignment
case verticalAlignment
case anchorView
Expand All @@ -31,6 +29,7 @@ class ViewController: UITableViewController {
case tableViewCell
#if os(iOS)
case collectionViewCell
case controls
case webView
case mapView
case animation
Expand Down Expand Up @@ -65,10 +64,8 @@ class ViewController: UITableViewController {
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) ?? UITableViewCell(style: .default, reuseIdentifier: cellIdentifier)

switch example {
#if os(iOS)
case .controls:
cell.textLabel?.text = "Controls"
#endif
case .greeting:
cell.textLabel?.text = "Greeting"

case .horizontalAlignment:
cell.textLabel?.text = "Horizontal Alignment"
Expand Down Expand Up @@ -97,6 +94,9 @@ class ViewController: UITableViewController {
case .collectionViewCell:
cell.textLabel?.text = "Collection View Cell"

case .controls:
cell.textLabel?.text = "Controls"

case .webView:
cell.textLabel?.text = "Web View"

Expand All @@ -120,10 +120,8 @@ class ViewController: UITableViewController {

let viewController: UIViewController
switch example {
#if os(iOS)
case .controls:
viewController = ControlsViewController(style: .grouped)
#endif
case .greeting:
viewController = GreetingViewController()

case .horizontalAlignment:
viewController = HorizontalAlignmentViewController()
Expand Down Expand Up @@ -157,6 +155,9 @@ class ViewController: UITableViewController {

viewController = CollectionViewCellController(collectionViewLayout: collectionViewLayout)

case .controls:
viewController = ControlsViewController(style: .grouped)

case .webView:
viewController = WebViewController()

Expand Down
Binary file added Lima-iOS/LimaTest/world.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Lima-tvOS/Lima-tvOS.xcodeproj/project.pbxproj
Expand Up @@ -53,6 +53,8 @@
37089955218E3E8500D03A00 /* LMRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 37089932218E3E8500D03A00 /* LMRootView.m */; };
37089956218E3E8500D03A00 /* LMSpacer.h in Headers */ = {isa = PBXBuildFile; fileRef = 37089933218E3E8500D03A00 /* LMSpacer.h */; settings = {ATTRIBUTES = (Public, ); }; };
37089957218E3E8500D03A00 /* LMColumnView.m in Sources */ = {isa = PBXBuildFile; fileRef = 37089934218E3E8500D03A00 /* LMColumnView.m */; };
374C583A2197066500500E12 /* GreetingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 374C58392197066500500E12 /* GreetingViewController.swift */; };
374C583C2197066C00500E12 /* world.png in Resources */ = {isa = PBXBuildFile; fileRef = 374C583B2197066C00500E12 /* world.png */; };
37E75048218616B200B06374 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 37E75047218616B200B06374 /* Assets.xcassets */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -125,6 +127,8 @@
37089932218E3E8500D03A00 /* LMRootView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LMRootView.m; path = "../../Lima-iOS/Lima/LMRootView.m"; sourceTree = "<group>"; };
37089933218E3E8500D03A00 /* LMSpacer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LMSpacer.h; path = "../../Lima-iOS/Lima/LMSpacer.h"; sourceTree = "<group>"; };
37089934218E3E8500D03A00 /* LMColumnView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LMColumnView.m; path = "../../Lima-iOS/Lima/LMColumnView.m"; sourceTree = "<group>"; };
374C58392197066500500E12 /* GreetingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GreetingViewController.swift; path = "../../Lima-iOS/LimaTest/GreetingViewController.swift"; sourceTree = "<group>"; };
374C583B2197066C00500E12 /* world.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = world.png; path = "../../Lima-iOS/LimaTest/world.png"; sourceTree = "<group>"; };
37D5266E218613A5005920C3 /* Lima.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Lima.framework; sourceTree = BUILT_PRODUCTS_DIR; };
37D52672218613A5005920C3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
37E7503E218616B100B06374 /* LimaTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LimaTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -217,6 +221,7 @@
children = (
370898F1218E3E7500D03A00 /* AppDelegate.swift */,
370898F5218E3E7500D03A00 /* ViewController.swift */,
374C58392197066500500E12 /* GreetingViewController.swift */,
370898FB218E3E7500D03A00 /* HorizontalAlignmentViewController.swift */,
370898FA218E3E7500D03A00 /* VerticalAlignmentViewController.swift */,
370898F0218E3E7400D03A00 /* AnchorViewController.swift */,
Expand All @@ -225,6 +230,7 @@
37E75047218616B200B06374 /* Assets.xcassets */,
370898F6218E3E7500D03A00 /* Icons.xcassets */,
37E75049218616B200B06374 /* Info.plist */,
374C583B2197066C00500E12 /* world.png */,
370898F8218E3E7500D03A00 /* pharmacies.json */,
);
path = LimaTest;
Expand Down Expand Up @@ -346,6 +352,7 @@
files = (
37089907218E3E7500D03A00 /* Icons.xcassets in Resources */,
37E75048218616B200B06374 /* Assets.xcassets in Resources */,
374C583C2197066C00500E12 /* world.png in Resources */,
37089909218E3E7500D03A00 /* pharmacies.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -388,6 +395,7 @@
files = (
37089902218E3E7500D03A00 /* AppDelegate.swift in Sources */,
37089906218E3E7500D03A00 /* ViewController.swift in Sources */,
374C583A2197066500500E12 /* GreetingViewController.swift in Sources */,
3708990C218E3E7500D03A00 /* HorizontalAlignmentViewController.swift in Sources */,
3708990B218E3E7500D03A00 /* VerticalAlignmentViewController.swift in Sources */,
3708990E218E3E7500D03A00 /* GridViewController.swift in Sources */,
Expand Down
14 changes: 8 additions & 6 deletions README.md
Expand Up @@ -75,8 +75,8 @@ Finally, Lima adds initializers to common UIKit views and controls to simplify t

```swift
let columnView = LMColumnView(
UIImageView(image: UIImage(named: "world.png")),
UILabel(text: "Hello, World!")
UIImageView(image: UIImage(named: "world.png"), contentMode: .scaleAspectFit),
UILabel(text: "Hello, World!", textAlignment: .center)
)
```

Expand All @@ -86,15 +86,17 @@ The same result could also be achieved as shown below:

```swift
let columnView = LMColumnView()

let imageView = UIImageView()
imageView.image = UIImage(named: "world.png")

imageView.contentMode = .scaleAspectFit

columnView.addSubview(imageView)

let label = UILabel()
label.text = "Hello, World!"

label.textAlignment = .center

columnView.addSubview(label)
```

Expand Down
Binary file modified README/hello-world.png
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 aeab310

Please sign in to comment.