Skip to content

Commit

Permalink
part two of the following implementation. isfollowing now works and y…
Browse files Browse the repository at this point in the history
…ou will see a follow/unfollow button when looking at a user (clicking doesnt do anything yet)
  • Loading branch information
intabulas committed May 6, 2009
1 parent ca9e74e commit f3866fd
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 33 deletions.
2 changes: 2 additions & 0 deletions Classes/FollowCell.h
Expand Up @@ -7,6 +7,8 @@
GHUser *user;
@private
IBOutlet UILabel *userLabel;
IBOutlet UIImageView *gravatarView;

}

@property (nonatomic, retain) GHUser *user;
Expand Down
2 changes: 2 additions & 0 deletions Classes/FollowCell.m
Expand Up @@ -9,6 +9,8 @@ - (void)setUser:(GHUser *)aUser {
[user release];
user = [aUser retain];
userLabel.text = user.login;
gravatarView.image = self.user.gravatar;

}

- (void)dealloc {
Expand Down
6 changes: 4 additions & 2 deletions Classes/GHUser.m
Expand Up @@ -38,9 +38,11 @@ - (NSString *)description {
return [NSString stringWithFormat:@"<GHUser login:'%@' isAuthenticated:'%@' status:'%d' name:'%@' email:'%@' company:'%@' location:'%@' blogURL:'%@' publicRepoCount:'%d' privateRepoCount:'%d'>", login, isAuthenticated ? @"YES" : @"NO", status, name, email, company, location, blogURL, publicRepoCount, privateRepoCount];
}

// FIXME Currently just stubbed out, see the issue:
// http://github.com/dbloete/ioctocat/issues#issue/5
- (BOOL)isFollowing:(GHUser *)anUser {
if ( !self.isFollowingLoaded ) return NO;
for ( GHUser *user in following ) {
if ( [user.login caseInsensitiveCompare:anUser.login] ) return YES;
}
return NO;
}

Expand Down
6 changes: 3 additions & 3 deletions Classes/UserController.m
Expand Up @@ -51,9 +51,9 @@ - (void)displayUser {
// FIXME Following needs to be implemented, see issue:
// http://github.com/dbloete/ioctocat/issues#issue/3
// if ([self.currentUser isEqual:user]) return;
// UIImage *buttonImage = [UIImage imageNamed:([self.currentUser isFollowing:user] ? @"UnfollowButton.png" : @"FollowButton.png")];
// [followButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
// followButton.hidden = NO;
UIImage *buttonImage = [UIImage imageNamed:([self.currentUser isFollowing:user] ? @"UnfollowButton.png" : @"FollowButton.png")];
[followButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
followButton.hidden = NO;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:object change:change context:context {
Expand Down
59 changes: 35 additions & 24 deletions FollowCell.xib
Expand Up @@ -41,24 +41,10 @@
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIImageView" id="852692412">
<reference key="NSNextResponder" ref="425256881"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{8, 11}, {16, 16}}</string>
<reference key="NSSuperview" ref="425256881"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<int key="IBUIContentMode">4</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">member.png</string>
</object>
</object>
<object class="IBUILabel" id="513702233">
<reference key="NSNextResponder" ref="425256881"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{33, 9}, {225, 20}}</string>
<string key="NSFrame">{{48, 10}, {225, 20}}</string>
<reference key="NSSuperview" ref="425256881"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
Expand All @@ -81,6 +67,14 @@
<float key="IBUIMinimumFontSize">1.000000e+01</float>
<int key="IBUINumberOfLines">2</int>
</object>
<object class="IBUIImageView" id="804357360">
<reference key="NSNextResponder" ref="425256881"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{11, 6}, {28, 28}}</string>
<reference key="NSSuperview" ref="425256881"/>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
</object>
</object>
<string key="NSFrameSize">{320, 40}</string>
<reference key="NSSuperview" ref="282112623"/>
Expand Down Expand Up @@ -126,6 +120,14 @@
</object>
<int key="connectionID">20</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">gravatarView</string>
<reference key="source" ref="282112623"/>
<reference key="destination" ref="804357360"/>
</object>
<int key="connectionID">24</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -154,19 +156,19 @@
<reference key="object" ref="282112623"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="852692412"/>
<reference ref="513702233"/>
<reference ref="804357360"/>
</object>
<reference key="parent" ref="957960031"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">12</int>
<reference key="object" ref="852692412"/>
<int key="objectID">13</int>
<reference key="object" ref="513702233"/>
<reference key="parent" ref="282112623"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="513702233"/>
<int key="objectID">23</int>
<reference key="object" ref="804357360"/>
<reference key="parent" ref="282112623"/>
</object>
</object>
Expand All @@ -180,8 +182,8 @@
<string>11.CustomClassName</string>
<string>11.IBEditorWindowLastContentRect</string>
<string>11.IBPluginDependency</string>
<string>12.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
<string>23.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -214,7 +216,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">20</int>
<int key="maxID">24</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -223,8 +225,17 @@
<string key="className">FollowCell</string>
<string key="superclassName">UITableViewCell</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">userLabel</string>
<string key="NS.object.0">UILabel</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>gravatarView</string>
<string>userLabel</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIImageView</string>
<string>UILabel</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
Expand Down
8 changes: 4 additions & 4 deletions IBFiles/FeedEntry.xib
Expand Up @@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1"/>
<integer value="3"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -67,7 +67,7 @@
<object class="IBUIImageView" id="1010474437">
<reference key="NSNextResponder" ref="206194869"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{12, 38}, {28, 28}}</string>
<string key="NSFrame">{{12, 37}, {28, 28}}</string>
<reference key="NSSuperview" ref="206194869"/>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
Expand Down Expand Up @@ -256,11 +256,11 @@
<reference key="object" ref="206194869"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1010474437"/>
<reference ref="105931350"/>
<reference ref="360035783"/>
<reference ref="521488189"/>
<reference ref="756434666"/>
<reference ref="1010474437"/>
</object>
<reference key="parent" ref="191373211"/>
</object>
Expand Down Expand Up @@ -317,7 +317,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>FeedEntryController</string>
<string>UIResponder</string>
<string>{{306, 348}, {320, 480}}</string>
<string>{{750, 325}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
Expand Down

0 comments on commit f3866fd

Please sign in to comment.