Skip to content

Commit

Permalink
added local time to the HomeVC, buttons are displaying correctly on F…
Browse files Browse the repository at this point in the history
…orecastVC. Deleted some corpse code from forecastVC.
  • Loading branch information
elaewin committed May 24, 2017
1 parent 6f5a856 commit a58e05c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
18 changes: 14 additions & 4 deletions CFuWx/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -49,7 +49,7 @@
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="WeatherIcon" translatesAutoresizingMaskIntoConstraints="NO" id="vzh-eD-yFD">
<rect key="frame" x="201" y="48" width="150" height="114"/>
<rect key="frame" x="201" y="52" width="150" height="110"/>
<color key="tintColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Summary" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GyG-Cz-Xbp">
Expand All @@ -70,11 +70,17 @@
<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="Time" textAlignment="right" lineBreakMode="wordWrap" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nHI-gL-gCY">
<rect key="frame" x="201" y="26" width="150" height="22"/>
<fontDescription key="fontDescription" name="AppleSDGothicNeo-SemiBold" family="Apple SD Gothic Neo" pointSize="18"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="vzh-eD-yFD" secondAttribute="trailing" constant="24" id="578-xv-rah"/>
<constraint firstItem="htT-X5-unD" firstAttribute="leading" secondItem="uEV-Dx-GAt" secondAttribute="leading" constant="16" id="Dff-18-w34"/>
<constraint firstItem="vzh-eD-yFD" firstAttribute="top" secondItem="d5T-hO-XNq" secondAttribute="bottom" constant="22" id="Dnh-gC-dP4"/>
<constraint firstItem="nHI-gL-gCY" firstAttribute="width" secondItem="d5T-hO-XNq" secondAttribute="width" id="EEj-WU-xTy"/>
<constraint firstItem="e9u-lJ-p74" firstAttribute="leading" secondItem="uEV-Dx-GAt" secondAttribute="leading" constant="16" id="EnB-oF-Q93"/>
<constraint firstItem="GyG-Cz-Xbp" firstAttribute="leading" secondItem="uEV-Dx-GAt" secondAttribute="leading" constant="16" id="MHk-ZL-muq"/>
<constraint firstAttribute="bottom" secondItem="vzh-eD-yFD" secondAttribute="bottom" constant="4" id="PpP-yU-4nN"/>
Expand All @@ -84,10 +90,13 @@
<constraint firstItem="e9u-lJ-p74" firstAttribute="top" secondItem="uEV-Dx-GAt" secondAttribute="top" constant="4" id="bEv-fT-w33"/>
<constraint firstItem="d5T-hO-XNq" firstAttribute="trailing" secondItem="vzh-eD-yFD" secondAttribute="trailing" id="beu-1M-BV3"/>
<constraint firstAttribute="bottom" secondItem="GyG-Cz-Xbp" secondAttribute="bottom" constant="20" id="br5-mO-bOc"/>
<constraint firstItem="nHI-gL-gCY" firstAttribute="trailing" secondItem="d5T-hO-XNq" secondAttribute="trailing" id="k8Y-1g-rW5"/>
<constraint firstItem="GyG-Cz-Xbp" firstAttribute="width" secondItem="uEV-Dx-GAt" secondAttribute="width" multiplier="0.45" id="kAf-Iv-QQY"/>
<constraint firstItem="nHI-gL-gCY" firstAttribute="top" secondItem="d5T-hO-XNq" secondAttribute="bottom" id="kJV-UA-NSB"/>
<constraint firstItem="vzh-eD-yFD" firstAttribute="width" secondItem="uEV-Dx-GAt" secondAttribute="width" multiplier="0.4" id="qHK-SH-tOH"/>
<constraint firstItem="d5T-hO-XNq" firstAttribute="top" secondItem="e9u-lJ-p74" secondAttribute="top" id="tNI-kE-cy4"/>
<constraint firstItem="e9u-lJ-p74" firstAttribute="width" secondItem="uEV-Dx-GAt" secondAttribute="width" multiplier="0.45" id="v1G-uJ-yIw"/>
<constraint firstItem="vzh-eD-yFD" firstAttribute="top" secondItem="nHI-gL-gCY" secondAttribute="bottom" constant="4" id="xqd-gr-FY1"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
Expand All @@ -96,6 +105,7 @@
<outlet property="location" destination="e9u-lJ-p74" id="Fam-a2-bfa"/>
<outlet property="summaryLabel" destination="GyG-Cz-Xbp" id="qh1-U9-CPI"/>
<outlet property="temperature" destination="htT-X5-unD" id="oKf-6l-OhY"/>
<outlet property="time" destination="nHI-gL-gCY" id="p9s-V4-J4d"/>
<outlet property="weatherIconImage" destination="vzh-eD-yFD" id="u4E-fv-339"/>
</connections>
</tableViewCell>
Expand Down
2 changes: 1 addition & 1 deletion CFuWx/Conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@interface Conversions : NSObject

// Number formatters
+(NSString *)getStringFormatFrom:(double)rawDouble to:(int)decimalPlaces;
+(NSString *)getStringFormatFrom:(double)rawDouble toPlaces:(int)decimalPlaces;
+(NSString *)formatToZeroDecimal:(double)numberToFormat;
+(NSString *)formatToOneDecimal:(double)numberToFormat;
+(NSString *)formatToTwoDecimals:(double)numberToFormat;
Expand Down
11 changes: 1 addition & 10 deletions CFuWx/ForecastViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

// still need to fix getting headers to display properly.
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

if ([self.forecastToDisplay isEqualToString:@"hourly"]) {
Expand All @@ -188,14 +187,6 @@ -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPat
return 65;
}

//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
// return 45;
//}

// code for background images from collections via unsplash
//-(NSURL *)getURLForLocalTimeOfForecast {
// return [NSURL URLWithString:@"https://source.unsplash.com/collection/566474"];
//}
-(BOOL)isItCurrentlyDaytime {
NSTimeInterval sunriseInterval = [self.dailyWeatherArray[0] sunriseTime].doubleValue;
NSTimeInterval sunsetInterval = [self.dailyWeatherArray[0] sunsetTime].doubleValue;
Expand All @@ -217,8 +208,8 @@ -(BOOL)isItCurrentlyDaytime {
}
}

// code for background images from collections via unsplash: setting background to image grabbed from "Forecast Backgrounds" collection in unsplash.com
-(UIImage *)getBackgroundImage {
// setting background to image grabbed from "Forecast Backgrounds" collection in unsplash.com

NSURL *imageURL = [[NSURL alloc] init];

Expand Down
4 changes: 2 additions & 2 deletions CFuWx/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
TopTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TopTableViewCell"];
NSDate *date = [NSDate date];

NSString *time = [Conversions convertToReadableTime:date];
cell.date.text = [NSString stringWithFormat:@"%@ at %@", [Conversions convertToReadableDate:date], time];
cell.time.text = [NSString stringWithFormat:@"%@ Local Time",[Conversions convertToReadableTime:date]];
cell.date.text = [Conversions convertToReadableDate:date];
cell.temperature.text = [NSString stringWithFormat:@"%@°F", [Conversions formatToOneDecimal:self.currentWeather.temperature.floatValue]];
cell.location.text = [self getLocationText];
[cell.weatherIconImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
Expand Down

0 comments on commit a58e05c

Please sign in to comment.