diff --git a/BMI.xcodeproj/project.pbxproj b/BMI.xcodeproj/project.pbxproj index 0444594..6e1099e 100644 --- a/BMI.xcodeproj/project.pbxproj +++ b/BMI.xcodeproj/project.pbxproj @@ -7,14 +7,17 @@ objects = { /* Begin PBXBuildFile section */ + 8A7C2F3E219CB339003210FE /* BMI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7C2F3D219CB339003210FE /* BMI.swift */; }; 8AF0CBF7219A4C950001A6D0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF0CBF6219A4C950001A6D0 /* AppDelegate.swift */; }; 8AF0CBF9219A4C950001A6D0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AF0CBF8219A4C950001A6D0 /* ViewController.swift */; }; 8AF0CBFC219A4C950001A6D0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8AF0CBFA219A4C950001A6D0 /* Main.storyboard */; }; 8AF0CBFE219A4C960001A6D0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8AF0CBFD219A4C960001A6D0 /* Assets.xcassets */; }; 8AF0CC01219A4C960001A6D0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8AF0CBFF219A4C960001A6D0 /* LaunchScreen.storyboard */; }; + 8AF0CC0A219A601B0001A6D0 /* DarkMode.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 8AF0CC08219A601B0001A6D0 /* DarkMode.xcdatamodeld */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 8A7C2F3D219CB339003210FE /* BMI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BMI.swift; sourceTree = ""; }; 8AF0CBF3219A4C950001A6D0 /* BMI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BMI.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8AF0CBF6219A4C950001A6D0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 8AF0CBF8219A4C950001A6D0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -22,6 +25,7 @@ 8AF0CBFD219A4C960001A6D0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8AF0CC00219A4C960001A6D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 8AF0CC02219A4C960001A6D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8AF0CC09219A601B0001A6D0 /* DarkMode.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DarkMode.xcdatamodel; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -60,6 +64,8 @@ 8AF0CBFD219A4C960001A6D0 /* Assets.xcassets */, 8AF0CBFF219A4C960001A6D0 /* LaunchScreen.storyboard */, 8AF0CC02219A4C960001A6D0 /* Info.plist */, + 8AF0CC08219A601B0001A6D0 /* DarkMode.xcdatamodeld */, + 8A7C2F3D219CB339003210FE /* BMI.swift */, ); path = BMI; sourceTree = ""; @@ -135,7 +141,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8A7C2F3E219CB339003210FE /* BMI.swift in Sources */, 8AF0CBF9219A4C950001A6D0 /* ViewController.swift in Sources */, + 8AF0CC0A219A601B0001A6D0 /* DarkMode.xcdatamodeld in Sources */, 8AF0CBF7219A4C950001A6D0 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -336,6 +344,19 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + 8AF0CC08219A601B0001A6D0 /* DarkMode.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + 8AF0CC09219A601B0001A6D0 /* DarkMode.xcdatamodel */, + ); + currentVersion = 8AF0CC09219A601B0001A6D0 /* DarkMode.xcdatamodel */; + path = DarkMode.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ }; rootObject = 8AF0CBEB219A4C950001A6D0 /* Project object */; } diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/Contents.json b/BMI/Assets.xcassets/AppIcon.appiconset/Contents.json index d8db8d6..5cab145 100644 --- a/BMI/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/BMI/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,93 +1,129 @@ { "images" : [ { - "idiom" : "iphone", "size" : "20x20", + "idiom" : "iphone", + "filename" : "icon_20pt@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "20x20", + "idiom" : "iphone", + "filename" : "icon_20pt@3x.png", "scale" : "3x" }, { + "size" : "29x29", "idiom" : "iphone", + "filename" : "icon_29pt.png", + "scale" : "1x" + }, + { "size" : "29x29", + "idiom" : "iphone", + "filename" : "icon_29pt@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "29x29", + "idiom" : "iphone", + "filename" : "icon_29pt@3x.png", "scale" : "3x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "icon_40pt@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "icon_40pt@3x.png", "scale" : "3x" }, { + "size" : "57x57", "idiom" : "iphone", - "size" : "60x60", + "filename" : "icon_57pt@1x.jpg", + "scale" : "1x" + }, + { + "size" : "57x57", + "idiom" : "iphone", + "filename" : "icon_57pt@2x.jpg", "scale" : "2x" }, { + "size" : "60x60", "idiom" : "iphone", + "filename" : "icon_60pt@2x.png", + "scale" : "2x" + }, + { "size" : "60x60", + "idiom" : "iphone", + "filename" : "icon_60pt@3x.png", "scale" : "3x" }, { - "idiom" : "ipad", "size" : "20x20", + "idiom" : "ipad", + "filename" : "icon_20pt-1.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "20x20", + "idiom" : "ipad", + "filename" : "icon_40pt-1.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "icon_29pt-1.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "icon_29pt@2x-1.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "icon_40pt.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "icon_40pt@2x-1.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "icon_76pt.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "icon_76pt@2x.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "icon_83.5@2x.png", "scale" : "2x" }, { - "idiom" : "ios-marketing", "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon.png", "scale" : "1x" } ], diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/Icon.png b/BMI/Assets.xcassets/AppIcon.appiconset/Icon.png new file mode 100644 index 0000000..942d326 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/Icon.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt-1.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt-1.png new file mode 100644 index 0000000..75e70a7 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt-1.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt@2x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt@2x.png new file mode 100644 index 0000000..dde56a3 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt@2x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt@3x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt@3x.png new file mode 100644 index 0000000..fee412d Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_20pt@3x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt-1.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt-1.png new file mode 100644 index 0000000..9d964b6 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt-1.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt.png new file mode 100644 index 0000000..9d964b6 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@2x-1.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@2x-1.png new file mode 100644 index 0000000..963e5c4 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@2x-1.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@2x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@2x.png new file mode 100644 index 0000000..963e5c4 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@2x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@3x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@3x.png new file mode 100644 index 0000000..0962509 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_29pt@3x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt-1.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt-1.png new file mode 100644 index 0000000..dde56a3 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt-1.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt.png new file mode 100644 index 0000000..dde56a3 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@2x-1.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@2x-1.png new file mode 100644 index 0000000..4304d35 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@2x-1.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@2x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@2x.png new file mode 100644 index 0000000..4304d35 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@2x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@3x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@3x.png new file mode 100644 index 0000000..fa8d8ad Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_40pt@3x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_57pt@1x.jpg b/BMI/Assets.xcassets/AppIcon.appiconset/icon_57pt@1x.jpg new file mode 100644 index 0000000..d45ec96 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_57pt@1x.jpg differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_57pt@2x.jpg b/BMI/Assets.xcassets/AppIcon.appiconset/icon_57pt@2x.jpg new file mode 100644 index 0000000..11500eb Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_57pt@2x.jpg differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_60pt@2x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_60pt@2x.png new file mode 100644 index 0000000..fa8d8ad Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_60pt@2x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_60pt@3x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_60pt@3x.png new file mode 100644 index 0000000..8ac1c8b Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_60pt@3x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_76pt.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_76pt.png new file mode 100644 index 0000000..301d599 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_76pt.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_76pt@2x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_76pt@2x.png new file mode 100644 index 0000000..6a35b3e Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_76pt@2x.png differ diff --git a/BMI/Assets.xcassets/AppIcon.appiconset/icon_83.5@2x.png b/BMI/Assets.xcassets/AppIcon.appiconset/icon_83.5@2x.png new file mode 100644 index 0000000..8d8a1f4 Binary files /dev/null and b/BMI/Assets.xcassets/AppIcon.appiconset/icon_83.5@2x.png differ diff --git a/BMI/Assets.xcassets/Button.imageset/Contents.json b/BMI/Assets.xcassets/Button.imageset/Contents.json new file mode 100644 index 0000000..c39050c --- /dev/null +++ b/BMI/Assets.xcassets/Button.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "redButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/BMI/Assets.xcassets/Button.imageset/redButton.png b/BMI/Assets.xcassets/Button.imageset/redButton.png new file mode 100644 index 0000000..e05d29e Binary files /dev/null and b/BMI/Assets.xcassets/Button.imageset/redButton.png differ diff --git a/BMI/Assets.xcassets/Button2.imageset/Contents.json b/BMI/Assets.xcassets/Button2.imageset/Contents.json new file mode 100644 index 0000000..3c71fe9 --- /dev/null +++ b/BMI/Assets.xcassets/Button2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "redButton2.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/BMI/Assets.xcassets/Button2.imageset/redButton2.png b/BMI/Assets.xcassets/Button2.imageset/redButton2.png new file mode 100644 index 0000000..53fe2fd Binary files /dev/null and b/BMI/Assets.xcassets/Button2.imageset/redButton2.png differ diff --git a/BMI/Assets.xcassets/Splash.imageset/Contents.json b/BMI/Assets.xcassets/Splash.imageset/Contents.json new file mode 100644 index 0000000..da507c0 --- /dev/null +++ b/BMI/Assets.xcassets/Splash.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Splash.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/BMI/Assets.xcassets/Splash.imageset/Splash.png b/BMI/Assets.xcassets/Splash.imageset/Splash.png new file mode 100644 index 0000000..762aa59 Binary files /dev/null and b/BMI/Assets.xcassets/Splash.imageset/Splash.png differ diff --git a/BMI/BMI.swift b/BMI/BMI.swift new file mode 100644 index 0000000..f293786 --- /dev/null +++ b/BMI/BMI.swift @@ -0,0 +1,22 @@ +// +// BMI.swift +// BMI +// +// Created by Kenneth W Jackson on 11/14/18. +// Copyright © 2018 Connections Digital. All rights reserved. +// + +import Foundation + + +//bmi = (myBMI.weight * 703) / (myBMI.height * myBMI.height) +public struct BMICalculator { + func bmi(height: Int, weight: Int) -> Int { + let bmiCalc = 703 * weight / (height * height) + return bmiCalc + } +} + + + + diff --git a/BMI/Base.lproj/LaunchScreen.storyboard b/BMI/Base.lproj/LaunchScreen.storyboard index bfa3612..0cf373d 100644 --- a/BMI/Base.lproj/LaunchScreen.storyboard +++ b/BMI/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,11 @@ - - + + + + + - + + @@ -11,15 +15,27 @@ - + - + + + + + + + + + + - + + + + diff --git a/BMI/Base.lproj/Main.storyboard b/BMI/Base.lproj/Main.storyboard index f1bcf38..9a4a147 100644 --- a/BMI/Base.lproj/Main.storyboard +++ b/BMI/Base.lproj/Main.storyboard @@ -1,7 +1,11 @@ - + + + + - + + @@ -9,16 +13,93 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BMI/DarkMode.xcdatamodeld/DarkMode.xcdatamodel/contents b/BMI/DarkMode.xcdatamodeld/DarkMode.xcdatamodel/contents new file mode 100644 index 0000000..ff6c9c9 --- /dev/null +++ b/BMI/DarkMode.xcdatamodeld/DarkMode.xcdatamodel/contents @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/BMI/Info.plist b/BMI/Info.plist index 16be3b6..89d7858 100644 --- a/BMI/Info.plist +++ b/BMI/Info.plist @@ -31,8 +31,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad diff --git a/BMI/ViewController.swift b/BMI/ViewController.swift index ba38492..5a6f7b5 100644 --- a/BMI/ViewController.swift +++ b/BMI/ViewController.swift @@ -10,11 +10,59 @@ import UIKit class ViewController: UIViewController { + // Gather data for BMI calculations + @IBOutlet weak var fldFeet: UITextField! + @IBOutlet weak var fldInches: UITextField! + @IBOutlet weak var fldWeight: UITextField! + + @IBAction func calculateBTN(_ sender: Any) { + + // Convert string data to itegers + let heightFeet = Int(fldFeet.text!) + let heightInches = Int(fldInches.text!) + let weightLbs = Int(fldWeight.text!) + + // Verify fields contain data + let heightFeetString = (fldFeet.text!) + let heightInchesString = (fldInches.text!) + let weightLbsString = (fldWeight.text!) + + if(heightFeetString.isEmpty) || (heightInchesString.isEmpty) || (weightLbsString.isEmpty) { + let myAlert = UIAlertController(title: "Alert", message: "All fields are required.", preferredStyle: UIAlertController.Style.alert) + + let okAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil) + + myAlert.addAction(okAction) + + self.present(myAlert, animated: true, completion: nil) + return + + } + + // Convert height in feet and inches to height in inches + let heightTotalInches = (heightFeet!*12) + heightInches! + + // Send BMI calculation data to BMI struct + let myBMI = BMICalculator() + + let bmiCalc = myBMI.bmi(height: heightTotalInches, weight: weightLbs!) + + // Display calculated BMI on device interface + lblResult.text = "Your BMI is \(bmiCalc)" + } + + @IBOutlet weak var lblResult: UILabel! + override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. - } + + // Show keyboard at startup + fldFeet.becomeFirstResponder() + + + } }