Permalink
Browse files

made pretty graphs

  • Loading branch information...
1 parent ae39286 commit c315bfa964deee92994137921631319fb565ca45 @orta orta committed Mar 25, 2012
@@ -33,6 +33,7 @@
6085D279151B9DBA0068929C /* V1PutIOClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 6085D278151B9DBA0068929C /* V1PutIOClient.m */; };
6085D27F151BA3AF0068929C /* NSDictionary+JSON.m in Sources */ = {isa = PBXBuildFile; fileRef = 6085D27E151BA3AF0068929C /* NSDictionary+JSON.m */; };
6085D297151BAB230068929C /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 6085D296151BAB230068929C /* Constants.m */; };
+ 60A7A6B5151F6E0D00DB71E0 /* ORSimpleProgress.m in Sources */ = {isa = PBXBuildFile; fileRef = 60A7A6B4151F6E0D00DB71E0 /* ORSimpleProgress.m */; };
60AB50D3151F650A00473448 /* UIColor+PutioColours.m in Sources */ = {isa = PBXBuildFile; fileRef = 60AB50D2151F650A00473448 /* UIColor+PutioColours.m */; };
60B1A92F151DFDA300FBCD27 /* NSString+Matching.m in Sources */ = {isa = PBXBuildFile; fileRef = 60B1A928151DFDA300FBCD27 /* NSString+Matching.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
60B1A930151DFDA300FBCD27 /* RSAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 60B1A92A151DFDA300FBCD27 /* RSAPI.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
@@ -92,6 +93,8 @@
6085D27E151BA3AF0068929C /* NSDictionary+JSON.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+JSON.m"; sourceTree = "<group>"; };
6085D295151BAB230068929C /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
6085D296151BAB230068929C /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = "<group>"; };
+ 60A7A6B3151F6E0D00DB71E0 /* ORSimpleProgress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ORSimpleProgress.h; path = Views/ORSimpleProgress.h; sourceTree = "<group>"; };
+ 60A7A6B4151F6E0D00DB71E0 /* ORSimpleProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ORSimpleProgress.m; path = Views/ORSimpleProgress.m; sourceTree = "<group>"; };
60AB50D1151F650A00473448 /* UIColor+PutioColours.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIColor+PutioColours.h"; path = "Categories/UIColor+PutioColours.h"; sourceTree = "<group>"; };
60AB50D2151F650A00473448 /* UIColor+PutioColours.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIColor+PutioColours.m"; path = "Categories/UIColor+PutioColours.m"; sourceTree = "<group>"; };
60B1A927151DFDA300FBCD27 /* NSString+Matching.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Matching.h"; sourceTree = "<group>"; };
@@ -128,6 +131,8 @@
6006420F151F639000EF85F9 /* Views */ = {
isa = PBXGroup;
children = (
+ 60A7A6B3151F6E0D00DB71E0 /* ORSimpleProgress.h */,
+ 60A7A6B4151F6E0D00DB71E0 /* ORSimpleProgress.m */,
);
name = Views;
sourceTree = "<group>";
@@ -382,6 +387,7 @@
60064202151F24CD00EF85F9 /* BrowsingViewController.m in Sources */,
60064205151F24DA00EF85F9 /* RootViewController.m in Sources */,
60AB50D3151F650A00473448 /* UIColor+PutioColours.m in Sources */,
+ 60A7A6B5151F6E0D00DB71E0 /* ORSimpleProgress.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -13,4 +13,5 @@
+ (PutIOClient *)sharedClient;
- (BOOL)ready;
+- (void)getUserInfo:(void(^)(id userInfoObject))onComplete;
@end
@@ -49,4 +49,10 @@ - (BOOL)ready {
return ([self.v1Client ready] && [self.v2Client ready]);
}
+- (void)getUserInfo:(void(^)(id userInfoObject))onComplete {
+ [self.v1Client getUserInfo:^(id userInfoObject) {
+ onComplete(userInfoObject);
+ }];
+}
+
@end
@@ -8,6 +8,10 @@
#import <UIKit/UIKit.h>
+@class ORSimpleProgress;
@interface StatusViewController : UIViewController
+
+@property (weak, nonatomic) IBOutlet ORSimpleProgress *bandwidthProgressView;
+@property (weak, nonatomic) IBOutlet ORSimpleProgress *spaceProgressView;
- (void)setup;
@end
@@ -8,12 +8,15 @@
#import "StatusViewController.h"
#import <QuartzCore/QuartzCore.h>
+#import "ORSimpleProgress.h"
@interface StatusViewController ()
@end
@implementation StatusViewController
+@synthesize bandwidthProgressView;
+@synthesize spaceProgressView;
- (void)setup {
CGRect space = [self.view.superview bounds];
@@ -25,9 +28,22 @@ - (void)setup {
- (void)viewDidLoad {
[super viewDidLoad];
[self setupShadow];
+
+ [[PutIOClient sharedClient] getUserInfo:^(id userInfoObject) {
+ NSString *diskQuotaString = [[userInfoObject valueForKeyPath:@"response.results.disk_quota"] objectAtIndex:0];
+ NSString *diskQuotaAvailableString = [[userInfoObject valueForKeyPath:@"response.results.disk_quota_available"] objectAtIndex:0];
+
+ NSString *bandwidthQuotaString = [[userInfoObject valueForKeyPath:@"response.results.bw_quota"] objectAtIndex:0];
+ NSString *bandwidthQuotaAvailableString = [[userInfoObject valueForKeyPath:@"response.results.bw_quota_available"] objectAtIndex:0];
+
+ self.spaceProgressView.value = [diskQuotaAvailableString longLongValue] / [diskQuotaString longLongValue] ;
+ self.bandwidthProgressView.value = [bandwidthQuotaAvailableString longLongValue] / [bandwidthQuotaString longLongValue];
+ }];
}
- (void)viewDidUnload {
+ [self setBandwidthProgressView:nil];
+ [self setSpaceProgressView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
@@ -0,0 +1,17 @@
+//
+// ORSimpleProgress.h
+// Puttio
+//
+// Created by orta therox on 25/03/2012.
+// Copyright (c) 2012 ortatherox.com. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ORSimpleProgress : UIView {
+ CGFloat value;
+}
+@property (strong) UILabel *label;
+@property (strong) UIColor *fillColour;
+@property CGFloat value;
+@end
@@ -0,0 +1,41 @@
+//
+// ORSimpleProgress.m
+// Puttio
+//
+// Created by orta therox on 25/03/2012.
+// Copyright (c) 2012 ortatherox.com. All rights reserved.
+//
+
+#import "ORSimpleProgress.h"
+
+@implementation ORSimpleProgress
+@synthesize label, fillColour;
+@dynamic value;
+
+- (void)awakeFromNib {
+ self.alpha = .3;
+ self.label = [[UILabel alloc] initWithFrame:self.frame];
+ value = .3;
+ self.backgroundColor = [UIColor putioBlue];
+ self.fillColour = [UIColor putioYellow];
+}
+
+- (void)drawRect:(CGRect)rect {
+ CGContextRef c = UIGraphicsGetCurrentContext();
+
+ CGContextSetFillColor(c, CGColorGetComponents(self.backgroundColor.CGColor));
+ CGContextFillRect(c, self.bounds);
+
+ CGRect filledRect = self.bounds;
+ filledRect.size.height = filledRect.size.height / value;
+ CGContextSetFillColor(c, CGColorGetComponents(self.fillColour.CGColor));
+ CGContextFillRect(c, filledRect);
+}
+
+- (void)setValue:(CGFloat)aValue {
+ self.alpha = 1;
+ value = aValue;
+ [self setNeedsDisplay];
+}
+
+@end
@@ -20,20 +20,48 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.97776401040000005" green="0.92181301120000003" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</view>
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Status" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="VsJ-Q3-TXw">
- <rect key="frame" x="154" y="6" width="111" height="32"/>
+ <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Status" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="VsJ-Q3-TXw">
+ <rect key="frame" x="12" y="6" width="111" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Futura-CondensedMedium" family="Futura" pointSize="28"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
+ <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Space" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="JVc-iZ-mfQ">
+ <rect key="frame" x="20" y="716" width="111" height="36"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <fontDescription key="fontDescription" name="Futura-CondensedMedium" family="Futura" pointSize="28"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Bandwidth" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="w79-AE-0mt">
+ <rect key="frame" x="144" y="716" width="111" height="36"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <fontDescription key="fontDescription" name="Futura-CondensedMedium" family="Futura" pointSize="28"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <view contentMode="scaleToFill" id="iLk-Zv-WaC" customClass="ORSimpleProgress">
+ <rect key="frame" x="30" y="545" width="66" height="163"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <color key="backgroundColor" red="0.42571601269999998" green="0.73212200400000005" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+ </view>
+ <view contentMode="scaleToFill" id="EYi-oQ-Ygh" customClass="ORSimpleProgress">
+ <rect key="frame" x="166" y="545" width="66" height="163"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <color key="backgroundColor" red="0.42571601269999998" green="0.73212200400000005" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+ </view>
</subviews>
<color key="backgroundColor" red="0.98062138971749735" green="1" blue="0.91727147853090318" alpha="1" colorSpace="calibratedRGB"/>
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
</view>
<nil key="simulatedStatusBarMetrics"/>
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+ <connections>
+ <outlet property="bandwidthProgressView" destination="EYi-oQ-Ygh" id="NAX-gO-wMV"/>
+ <outlet property="spaceProgressView" destination="iLk-Zv-WaC" id="rRm-Cg-doo"/>
+ </connections>
</viewController>
</objects>
<point key="canvasLocation" x="-3607" y="-1544"/>
@@ -157,6 +185,9 @@
<relationship kind="outlet" name="webView" candidateClass="UIWebView"/>
</relationships>
</class>
+ <class className="ORSimpleProgress" superclassName="UIView">
+ <source key="sourceIdentifier" type="project" relativePath="./Classes/ORSimpleProgress.h"/>
+ </class>
<class className="RootViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/RootViewController.h"/>
</class>
@@ -168,6 +199,10 @@
</class>
<class className="StatusViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/StatusViewController.h"/>
+ <relationships>
+ <relationship kind="outlet" name="bandwidthProgressView" candidateClass="ORSimpleProgress"/>
+ <relationship kind="outlet" name="spaceProgressView" candidateClass="ORSimpleProgress"/>
+ </relationships>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">

0 comments on commit c315bfa

Please sign in to comment.