Skip to content

Commit

Permalink
Merge pull request #67 from fbu-team-awesome/display-checked-in-users
Browse files Browse the repository at this point in the history
Display checked in users
  • Loading branch information
britphan committed Aug 1, 2018
2 parents 8bb0619 + 680e346 commit d2ac483
Show file tree
Hide file tree
Showing 12 changed files with 407 additions and 6 deletions.
1 change: 1 addition & 0 deletions Models/PFUser+ExtendedUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
+ (void)retrieveUsersWithIDs:(NSArray<NSString*>*)IDs withCompletion:(void(^)(NSArray<PFUser*>*))completion;
- (void)addCheckIn:(NSString *)placeID withCompletion:(void(^)(void))completion;
- (void)retrieveCheckInCountForPlaceID:(NSString *)placeID withCompletion:(void(^)(NSNumber *))completion;
+ (void)getFollowingWithinUserArray:(NSArray <NSString*>*) objectIds withCompletion:(void(^)(NSArray <NSString*>*))completion;

@end
14 changes: 14 additions & 0 deletions Models/PFUser+ExtendedUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,20 @@ + (void)retrieveUsersWithIDs:(NSArray<NSString*>*)IDs withCompletion:(void(^)(NS
}
}

+ (void)getFollowingWithinUserArray:(NSArray <NSString*>*) objectIds withCompletion:(void(^)(NSArray <NSString*>*))completion{
[Relationships retrieveFollowingWithId:[PFUser currentUser].relationships.objectId WithCompletion:^(NSArray * _Nullable following) {
NSMutableArray *mutableUsers = [[NSMutableArray alloc] init];
NSSet *followingSet = [NSSet setWithArray:following];

for (NSString *objectId in objectIds){
if ([followingSet containsObject:objectId]) {
[mutableUsers addObject:objectId];
}
}
completion([mutableUsers copy]);
}];
}

#pragma mark - Check-in Helper Methods

- (void)addCheckIn:(NSString *)placeID withCompletion:(void(^)(void))completion{
Expand Down
1 change: 1 addition & 0 deletions Models/Place.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

- (nonnull instancetype)initWithGMSPlace:(nonnull GMSPlace*)place;
- (void) didCheckIn:(nonnull PFUser *)user;
- (void)getUsersCheckedInWithCompletion:(void(^ _Nonnull)(NSArray <NSString*>*_Nullable))completion;
+ (void)checkPlaceWithIDExists:(nonnull NSString *)placeID result:(void(^_Nonnull)(Place*_Nonnull))result;
+ (void)checkGMSPlaceExists:(nonnull GMSPlace*)place result:(void(^_Nonnull)(Place* _Nonnull))result;

Expand Down
12 changes: 12 additions & 0 deletions Models/Place.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ + (void)checkPlaceWithIDExists:(NSString *)placeID result:(void(^)(Place*))resul
- (void)didCheckIn:(PFUser *)user {
[self addObject:user.objectId forKey:@"checkIns"];
[self saveInBackground];

}

- (void)getUsersCheckedInWithCompletion:(void(^)(NSArray <NSString*>*))completion {
PFQuery* query = [PFQuery queryWithClassName:@"Place"];
[query getObjectInBackgroundWithId:self.objectId block:^(PFObject * _Nullable object, NSError * _Nullable error) {
if(error != nil) {
NSLog(@"Error: %@", error.localizedDescription);
} else {
completion(object[@"checkIns"]);
}
}];
}

@end
121 changes: 121 additions & 0 deletions Storyboards/CheckIns.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="sjx-nH-l2h">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Check-Ins-->
<scene sceneID="CFB-4i-qdW">
<objects>
<viewController title="Check-Ins" id="sjx-nH-l2h" customClass="CheckInsViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ctm-wA-PWm">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="48" estimatedRowHeight="48" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="vPG-xu-FJ9">
<rect key="frame" x="0.0" y="64" width="375" height="541"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="CheckInCell" rowHeight="54" id="kAk-oz-sub" customClass="RelationshipListCell">
<rect key="frame" x="0.0" y="28" width="375" height="54"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="kAk-oz-sub" id="SHq-c3-Ax6">
<rect key="frame" x="0.0" y="0.0" width="375" height="53.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="gcb-g0-BL5">
<rect key="frame" x="8" y="8" width="104" height="32"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Hhl-Ot-7Fv">
<rect key="frame" x="0.0" y="0.0" width="32" height="32"/>
<color key="backgroundColor" name="VTR_Main"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="76A-KN-t6W"/>
<constraint firstAttribute="width" constant="32" id="rej-cZ-uKm"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="H8X-8q-I1s">
<rect key="frame" x="40" y="0.0" width="64" height="32"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="My Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="87H-xh-Hlx">
<rect key="frame" x="0.0" y="0.0" width="64" height="16.5"/>
<constraints>
<constraint firstAttribute="height" constant="16.5" id="vaD-pG-cgV"/>
</constraints>
<fontDescription key="fontDescription" name="AvenirNext-Bold" family="Avenir Next" pointSize="12"/>
<color key="textColor" name="VTR_BlackLabel"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="@username" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sba-YI-MMt">
<rect key="frame" x="0.0" y="16.5" width="64" height="15.5"/>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="12"/>
<color key="textColor" name="VTR_GrayLabel"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="32" id="Kjc-6J-xka"/>
</constraints>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Palo Alto, CA" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="j3f-BR-PeV">
<rect key="frame" x="296" y="18.5" width="71" height="16.5"/>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="12"/>
<color key="textColor" name="VTR_GrayLabel"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="j3f-BR-PeV" secondAttribute="trailing" constant="8" id="9Uo-WI-wxu"/>
<constraint firstItem="j3f-BR-PeV" firstAttribute="centerY" secondItem="SHq-c3-Ax6" secondAttribute="centerY" id="S4t-RD-RsW"/>
<constraint firstItem="gcb-g0-BL5" firstAttribute="leading" secondItem="SHq-c3-Ax6" secondAttribute="leading" constant="8" id="Xac-cc-e1X"/>
<constraint firstItem="gcb-g0-BL5" firstAttribute="top" secondItem="SHq-c3-Ax6" secondAttribute="top" constant="8" id="sGu-Gb-PG5"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="hometownLabel" destination="j3f-BR-PeV" id="7Of-O8-KUP"/>
<outlet property="nameLabel" destination="87H-xh-Hlx" id="dVB-LI-xn5"/>
<outlet property="profileImage" destination="Hhl-Ot-7Fv" id="1KO-Nj-QMt"/>
<outlet property="usernameLabel" destination="sba-YI-MMt" id="Wi7-UQ-92u"/>
</connections>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="Oi1-2R-jNg"/>
</view>
<navigationItem key="navigationItem" id="jSL-hh-ETe"/>
<connections>
<outlet property="tableView" destination="vPG-xu-FJ9" id="5vi-jj-aQ4"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="aVv-aL-ijS" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1039.2" y="84.107946026986511"/>
</scene>
</scenes>
<resources>
<namedColor name="VTR_BlackLabel">
<color red="0.32549019607843138" green="0.32549019607843138" blue="0.32549019607843138" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="VTR_GrayLabel">
<color red="0.65098039215686276" green="0.65098039215686276" blue="0.65098039215686276" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="VTR_GrayLabel">
<color red="0.65098039220000004" green="0.65098039220000004" blue="0.65098039220000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="VTR_Main">
<color red="1" green="0.60392156860000001" blue="0.47058823529999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
Loading

0 comments on commit d2ac483

Please sign in to comment.