Commit 5111c4db95e4df273bcbadf33d71ef7c67f9d5d5
1 parent
7f9c2f9ce5
Exists in
master
and in
1 other branch
Share facebook, twitter
Showing 7 changed files with 137 additions and 20 deletions Side-by-side Diff
LifeLog/LifeLog.xcodeproj/project.pbxproj
| ... | ... | @@ -49,6 +49,7 @@ |
| 49 | 49 | E9373E4D1F361A230059355A /* HistoryGraphObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E9373E4C1F361A230059355A /* HistoryGraphObject.m */; }; |
| 50 | 50 | E9682E2E1F39675A00FE05A2 /* RankingTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E9682E2C1F39675A00FE05A2 /* RankingTableViewCell.m */; }; |
| 51 | 51 | E9682E2F1F39675A00FE05A2 /* RankingTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E9682E2D1F39675A00FE05A2 /* RankingTableViewCell.xib */; }; |
| 52 | + E997E0261F3AB66500709FB1 /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E997E0251F3AB66500709FB1 /* Social.framework */; }; | |
| 52 | 53 | E99E13AB1F336F3600C78787 /* CollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = E99E13AA1F336F3600C78787 /* CollectionView.m */; }; |
| 53 | 54 | E99E13AD1F336F4500C78787 /* CollectionView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E99E13AC1F336F4500C78787 /* CollectionView.xib */; }; |
| 54 | 55 | E99E13B11F33720600C78787 /* LabelCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E99E13AF1F33720600C78787 /* LabelCollectionViewCell.m */; }; |
| ... | ... | @@ -151,6 +152,7 @@ |
| 151 | 152 | E9682E2B1F39675A00FE05A2 /* RankingTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankingTableViewCell.h; sourceTree = "<group>"; }; |
| 152 | 153 | E9682E2C1F39675A00FE05A2 /* RankingTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankingTableViewCell.m; sourceTree = "<group>"; }; |
| 153 | 154 | E9682E2D1F39675A00FE05A2 /* RankingTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RankingTableViewCell.xib; sourceTree = "<group>"; }; |
| 155 | + E997E0251F3AB66500709FB1 /* Social.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Social.framework; path = System/Library/Frameworks/Social.framework; sourceTree = SDKROOT; }; | |
| 154 | 156 | E99E13A91F336F3600C78787 /* CollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionView.h; sourceTree = "<group>"; }; |
| 155 | 157 | E99E13AA1F336F3600C78787 /* CollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollectionView.m; sourceTree = "<group>"; }; |
| 156 | 158 | E99E13AC1F336F4500C78787 /* CollectionView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CollectionView.xib; sourceTree = "<group>"; }; |
| ... | ... | @@ -167,6 +169,7 @@ |
| 167 | 169 | isa = PBXFrameworksBuildPhase; |
| 168 | 170 | buildActionMask = 2147483647; |
| 169 | 171 | files = ( |
| 172 | + E997E0261F3AB66500709FB1 /* Social.framework in Frameworks */, | |
| 170 | 173 | 011799F0F2B47D80472673CE /* Pods_LifeLog.framework in Frameworks */, |
| 171 | 174 | ); |
| 172 | 175 | runOnlyForDeploymentPostprocessing = 0; |
| ... | ... | @@ -191,6 +194,7 @@ |
| 191 | 194 | 020C1721B642EF36F31E1BB4 /* Frameworks */ = { |
| 192 | 195 | isa = PBXGroup; |
| 193 | 196 | children = ( |
| 197 | + E997E0251F3AB66500709FB1 /* Social.framework */, | |
| 194 | 198 | 2D9F4ED6F06C8F252B9EAF48 /* Pods_LifeLog.framework */, |
| 195 | 199 | ); |
| 196 | 200 | name = Frameworks; |
LifeLog/LifeLog/CollectionView.h
| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | NSInteger _number; |
| 13 | 13 | int _selectedIndex; |
| 14 | 14 | |
| 15 | + BOOL _isEnableSelection; | |
| 15 | 16 | float _spacing; |
| 16 | 17 | float _cornerRadius; |
| 17 | 18 | |
| ... | ... | @@ -27,6 +28,7 @@ |
| 27 | 28 | @property (weak, nonatomic) IBOutlet UIView *view; |
| 28 | 29 | @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; |
| 29 | 30 | |
| 31 | +-(void) disableSelection; | |
| 30 | 32 | -(void) setButtonNumber: (NSInteger) number; |
| 31 | 33 | -(void) setSpacing: (float) spacing; |
| 32 | 34 | -(void) setCornerRadius: (float) radius; |
LifeLog/LifeLog/CollectionView.m
| ... | ... | @@ -24,6 +24,8 @@ |
| 24 | 24 | _highlightColor = [Utilities convertHecToColor:0x999999]; |
| 25 | 25 | _normalColor = [UIColor whiteColor]; |
| 26 | 26 | _textColor = [UIColor blackColor]; |
| 27 | + _isEnableSelection = true; | |
| 28 | + _selectedIndex = 0; | |
| 27 | 29 | } |
| 28 | 30 | return self; |
| 29 | 31 | } |
| ... | ... | @@ -33,6 +35,13 @@ |
| 33 | 35 | [self.collectionView registerNib:[UINib nibWithNibName:@"LabelCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"LabelCell"]; |
| 34 | 36 | } |
| 35 | 37 | |
| 38 | + | |
| 39 | +-(void) disableSelection { | |
| 40 | + _isEnableSelection = false; | |
| 41 | + _selectedIndex = -1; | |
| 42 | + [self.collectionView reloadData]; | |
| 43 | +} | |
| 44 | + | |
| 36 | 45 | -(void) setButtonNumber: (NSInteger) number { |
| 37 | 46 | _number = number; |
| 38 | 47 | } |
| ... | ... | @@ -91,9 +100,13 @@ |
| 91 | 100 | } |
| 92 | 101 | |
| 93 | 102 | -(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { |
| 94 | - _selectedIndex = indexPath.row; | |
| 95 | - [collectionView reloadData]; | |
| 96 | - self.changeCurrentIndex(_selectedIndex); | |
| 103 | + if(_isEnableSelection) { | |
| 104 | + _selectedIndex = indexPath.row; | |
| 105 | + [collectionView reloadData]; | |
| 106 | + } | |
| 107 | + if(self.changeCurrentIndex != NULL) { | |
| 108 | + self.changeCurrentIndex(_selectedIndex); | |
| 109 | + } | |
| 97 | 110 | } |
| 98 | 111 | @end |
LifeLog/LifeLog/HistoryViewController.m
| ... | ... | @@ -72,8 +72,14 @@ |
| 72 | 72 | NSArray *shareTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.share.1", nil), NSLocalizedString(@"lifelog.history.share.2", nil), NSLocalizedString(@"lifelog.history.share.3", nil), NSLocalizedString(@"lifelog.history.share.4", nil), NSLocalizedString(@"lifelog.history.share.5", nil), nil]; |
| 73 | 73 | [self.viewCollectionShare setButtonNumber:typeTitle.count]; |
| 74 | 74 | [self.viewCollectionShare setSpacing:3]; |
| 75 | - [self.viewCollectionShare setSelectedIndex:-1]; | |
| 76 | 75 | [self.viewCollectionShare setArrayTitle:shareTitle]; |
| 76 | + [self.viewCollectionShare disableSelection]; | |
| 77 | + | |
| 78 | + //add tap gesture for enable tap on gesture on CollectionView in ScrollView | |
| 79 | + UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gestureAction:)]; | |
| 80 | + [recognizer setNumberOfTapsRequired:1]; | |
| 81 | + self.scrollView.userInteractionEnabled = YES; | |
| 82 | + [self.scrollView addGestureRecognizer:recognizer]; | |
| 77 | 83 | } |
| 78 | 84 | |
| 79 | 85 | - (void)setupChartView { |
| 80 | 86 | |
| ... | ... | @@ -204,9 +210,35 @@ |
| 204 | 210 | [UIView animateWithDuration:0.5 animations:^{ |
| 205 | 211 | self.tableListHistory.alpha = alphaValue; |
| 206 | 212 | self.scrollView.alpha = 1.0 - alphaValue; |
| 207 | - } completion:^(bool completed) { | |
| 213 | + } completion:^(BOOL completed) { | |
| 208 | 214 | [self callRequestToUpdateData]; |
| 209 | 215 | }]; |
| 216 | +} | |
| 217 | + | |
| 218 | +-(void)gestureAction:(UITapGestureRecognizer *) sender | |
| 219 | +{ | |
| 220 | + CGPoint touchLocation = [sender locationOfTouch:0 inView:self.viewCollectionShare]; | |
| 221 | + NSIndexPath *indexPath = [self.viewCollectionShare.collectionView indexPathForItemAtPoint:touchLocation]; | |
| 222 | + NSString * content = @"Finish 500 steps"; | |
| 223 | + HistoryViewController __weak *weakSelf = self; | |
| 224 | + if(indexPath != NULL) { | |
| 225 | + switch (indexPath.row) { | |
| 226 | + case 0: //share facebook | |
| 227 | + [Utilities shareFacebook:content withViewController:weakSelf]; | |
| 228 | + break; | |
| 229 | + case 1: //share twitter | |
| 230 | + [Utilities shareTwitter:content withViewController:weakSelf]; | |
| 231 | + break; | |
| 232 | + case 2 : //share line | |
| 233 | + [Utilities shareLine:content withViewController:weakSelf]; | |
| 234 | + break; | |
| 235 | + case 3: // share email | |
| 236 | + [Utilities shareEmail:content withViewController:weakSelf]; | |
| 237 | + break; | |
| 238 | + default: | |
| 239 | + break; | |
| 240 | + } | |
| 241 | + } | |
| 210 | 242 | } |
| 211 | 243 | |
| 212 | 244 | #pragma mark UITableView Delegate |
LifeLog/LifeLog/HistoryViewController.xib
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 3 | 3 | <device id="retina4_7" orientation="portrait"> |
| 4 | 4 | <adaptation id="fullscreen"/> |
| 5 | 5 | </device> |
| 6 | 6 | <dependencies> |
| 7 | - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/> | |
| 7 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> | |
| 8 | 8 | <capability name="Aspect ratio constraints" minToolsVersion="5.1"/> |
| 9 | 9 | <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
| 10 | 10 | </dependencies> |
| 11 | 11 | |
| ... | ... | @@ -136,11 +136,11 @@ |
| 136 | 136 | <outlet property="delegate" destination="-1" id="Jka-Ij-zNq"/> |
| 137 | 137 | </connections> |
| 138 | 138 | </tableView> |
| 139 | - <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rey-N3-l8b"> | |
| 140 | - <rect key="frame" x="0.0" y="0.0" width="375" height="411"/> | |
| 139 | + <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rey-N3-l8b"> | |
| 140 | + <rect key="frame" x="0.0" y="0.0" width="375" height="421"/> | |
| 141 | 141 | <subviews> |
| 142 | - <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Cam-ML-IEO"> | |
| 143 | - <rect key="frame" x="0.0" y="0.0" width="375" height="411"/> | |
| 142 | + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cam-ML-IEO"> | |
| 143 | + <rect key="frame" x="0.0" y="0.0" width="375" height="421"/> | |
| 144 | 144 | <subviews> |
| 145 | 145 | <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kzk-mN-AOf"> |
| 146 | 146 | <rect key="frame" x="20" y="30" width="120" height="120"/> |
| ... | ... | @@ -155,7 +155,7 @@ |
| 155 | 155 | <nil key="highlightedColor"/> |
| 156 | 156 | </label> |
| 157 | 157 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kr7-S0-Fpl"> |
| 158 | - <rect key="frame" x="20.5" y="61" width="80" height="42"/> | |
| 158 | + <rect key="frame" x="20" y="61" width="80" height="42"/> | |
| 159 | 159 | <constraints> |
| 160 | 160 | <constraint firstAttribute="width" constant="80" id="IOc-sB-dA2"/> |
| 161 | 161 | <constraint firstAttribute="height" constant="42" id="zRP-Fu-qZ9"/> |
| ... | ... | @@ -187,7 +187,7 @@ |
| 187 | 187 | <rect key="frame" x="148" y="30" width="219" height="120"/> |
| 188 | 188 | <subviews> |
| 189 | 189 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="็ฎๆจ" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YE6-wh-77T" customClass="AutoTransLabel"> |
| 190 | - <rect key="frame" x="10" y="37.5" width="45" height="15"/> | |
| 190 | + <rect key="frame" x="10" y="38" width="45" height="15"/> | |
| 191 | 191 | <constraints> |
| 192 | 192 | <constraint firstAttribute="width" constant="45" id="6Ce-YE-wbx"/> |
| 193 | 193 | <constraint firstAttribute="height" constant="15" id="eFR-Ao-75U"/> |
| ... | ... | @@ -200,7 +200,7 @@ |
| 200 | 200 | </userDefinedRuntimeAttributes> |
| 201 | 201 | </label> |
| 202 | 202 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ๆฎๆญฉๆฐ" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HOl-Tj-xiT" customClass="AutoTransLabel"> |
| 203 | - <rect key="frame" x="10" y="52.5" width="45" height="15"/> | |
| 203 | + <rect key="frame" x="10" y="53" width="45" height="15"/> | |
| 204 | 204 | <fontDescription key="fontDescription" type="system" pointSize="12"/> |
| 205 | 205 | <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> |
| 206 | 206 | <nil key="highlightedColor"/> |
| ... | ... | @@ -209,7 +209,7 @@ |
| 209 | 209 | </userDefinedRuntimeAttributes> |
| 210 | 210 | </label> |
| 211 | 211 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="้ๆ็" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l0h-qA-2Ai" customClass="AutoTransLabel"> |
| 212 | - <rect key="frame" x="10" y="67.5" width="45" height="15"/> | |
| 212 | + <rect key="frame" x="10" y="68" width="45" height="15"/> | |
| 213 | 213 | <fontDescription key="fontDescription" type="system" pointSize="12"/> |
| 214 | 214 | <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> |
| 215 | 215 | <nil key="highlightedColor"/> |
| ... | ... | @@ -218,7 +218,7 @@ |
| 218 | 218 | </userDefinedRuntimeAttributes> |
| 219 | 219 | </label> |
| 220 | 220 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000 step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0pf-fX-QXT"> |
| 221 | - <rect key="frame" x="63" y="37.5" width="118" height="15"/> | |
| 221 | + <rect key="frame" x="63" y="38" width="118" height="15"/> | |
| 222 | 222 | <constraints> |
| 223 | 223 | <constraint firstAttribute="height" constant="15" id="Z6o-LI-Eu9"/> |
| 224 | 224 | </constraints> |
| 225 | 225 | |
| ... | ... | @@ -227,13 +227,13 @@ |
| 227 | 227 | <nil key="highlightedColor"/> |
| 228 | 228 | </label> |
| 229 | 229 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="500 step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1NH-b3-ST8"> |
| 230 | - <rect key="frame" x="63" y="52.5" width="118" height="15"/> | |
| 230 | + <rect key="frame" x="63" y="53" width="118" height="15"/> | |
| 231 | 231 | <fontDescription key="fontDescription" type="system" pointSize="12"/> |
| 232 | 232 | <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> |
| 233 | 233 | <nil key="highlightedColor"/> |
| 234 | 234 | </label> |
| 235 | 235 | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="50 %" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8Ru-Jc-Ouv"> |
| 236 | - <rect key="frame" x="63" y="67.5" width="118" height="15"/> | |
| 236 | + <rect key="frame" x="63" y="68" width="118" height="15"/> | |
| 237 | 237 | <fontDescription key="fontDescription" type="system" pointSize="12"/> |
| 238 | 238 | <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> |
| 239 | 239 | <nil key="highlightedColor"/> |
| ... | ... | @@ -429,6 +429,7 @@ |
| 429 | 429 | </subviews> |
| 430 | 430 | <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> |
| 431 | 431 | <constraints> |
| 432 | + <constraint firstItem="Cam-ML-IEO" firstAttribute="centerY" secondItem="rey-N3-l8b" secondAttribute="centerY" id="0WD-1q-SWm"/> | |
| 432 | 433 | <constraint firstItem="Cam-ML-IEO" firstAttribute="width" secondItem="rey-N3-l8b" secondAttribute="width" id="LbF-3h-cxa"/> |
| 433 | 434 | <constraint firstAttribute="trailing" secondItem="Cam-ML-IEO" secondAttribute="trailing" id="UHb-6d-wF8"/> |
| 434 | 435 | <constraint firstItem="Cam-ML-IEO" firstAttribute="leading" secondItem="rey-N3-l8b" secondAttribute="leading" id="Y4U-kD-V28"/> |
| 435 | 436 | |
| ... | ... | @@ -479,12 +480,12 @@ |
| 479 | 480 | </constraints> |
| 480 | 481 | <point key="canvasLocation" x="26.5" y="52.5"/> |
| 481 | 482 | </view> |
| 482 | - <swipeGestureRecognizer direction="left" id="Qjg-St-rCc"> | |
| 483 | + <swipeGestureRecognizer enabled="NO" cancelsTouchesInView="NO" direction="left" id="Qjg-St-rCc"> | |
| 483 | 484 | <connections> |
| 484 | 485 | <action selector="swipeAction:" destination="-1" id="2Vl-bM-Ta7"/> |
| 485 | 486 | </connections> |
| 486 | 487 | </swipeGestureRecognizer> |
| 487 | - <swipeGestureRecognizer direction="right" id="VSZ-i0-Jhb"> | |
| 488 | + <swipeGestureRecognizer cancelsTouchesInView="NO" direction="right" id="VSZ-i0-Jhb"> | |
| 488 | 489 | <connections> |
| 489 | 490 | <action selector="swipeAction:" destination="-1" id="hoY-6M-DoS"/> |
| 490 | 491 | </connections> |
LifeLog/LifeLog/Utilities.h
| ... | ... | @@ -13,5 +13,11 @@ |
| 13 | 13 | + (NSString *)addCommaFromNumber:(NSInteger)number; |
| 14 | 14 | + (UIColor *)convertHecToColor:(int) hex; |
| 15 | 15 | + (void)showErrorMessage:(NSString *)message withViewController:(UIViewController *)vc; |
| 16 | + | |
| 17 | +//share function | |
| 18 | ++ (void) shareFacebook : (NSString *) content withViewController:(UIViewController *)vc; | |
| 19 | ++ (void) shareTwitter : (NSString *) content withViewController:(UIViewController *)vc; | |
| 20 | ++ (void) shareLine : (NSString *) content withViewController:(UIViewController *)vc; | |
| 21 | ++ (void) shareEmail : (NSString *) content withViewController:(UIViewController *)vc; | |
| 16 | 22 | @end |
LifeLog/LifeLog/Utilities.m
| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | // Copyright ยฉ 2017 PhongNV. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | +#import <Social/Social.h> | |
| 10 | + | |
| 9 | 11 | #import "Utilities.h" |
| 10 | 12 | |
| 11 | 13 | @implementation Utilities |
| ... | ... | @@ -48,5 +50,62 @@ |
| 48 | 50 | } |
| 49 | 51 | } |
| 50 | 52 | |
| 53 | ++ (void) shareFacebook : (NSString *) content withViewController:(UIViewController *)vc { | |
| 54 | + if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) | |
| 55 | + { | |
| 56 | + SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; | |
| 57 | + | |
| 58 | + [composeViewController setInitialText:content]; | |
| 59 | + [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) { | |
| 60 | + | |
| 61 | + switch (result) { | |
| 62 | + case SLComposeViewControllerResultCancelled: | |
| 63 | + NSLog(@"canceled"); | |
| 64 | + break; | |
| 65 | + case SLComposeViewControllerResultDone: | |
| 66 | + NSLog(@"done"); | |
| 67 | + break; | |
| 68 | + default: | |
| 69 | + break; | |
| 70 | + } | |
| 71 | + }]; | |
| 72 | + [vc presentViewController:composeViewController animated:YES completion:nil]; | |
| 73 | + } | |
| 74 | + else { | |
| 75 | + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=FACEBOOK"]]; | |
| 76 | + } | |
| 77 | +} | |
| 78 | + | |
| 79 | ++ (void) shareTwitter : (NSString *) content withViewController:(UIViewController *)vc { | |
| 80 | + if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) | |
| 81 | + { | |
| 82 | + SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; | |
| 83 | + | |
| 84 | + [composeViewController setInitialText:content]; | |
| 85 | + [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) { | |
| 86 | + | |
| 87 | + switch (result) { | |
| 88 | + case SLComposeViewControllerResultCancelled: | |
| 89 | + NSLog(@"canceled"); | |
| 90 | + break; | |
| 91 | + case SLComposeViewControllerResultDone: | |
| 92 | + NSLog(@"done"); | |
| 93 | + break; | |
| 94 | + default: | |
| 95 | + break; | |
| 96 | + } | |
| 97 | + }]; | |
| 98 | + [vc presentViewController:composeViewController animated:YES completion:nil]; | |
| 99 | + } | |
| 100 | + else { | |
| 101 | + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=TWITTER"]]; | |
| 102 | + } | |
| 103 | +} | |
| 104 | + | |
| 105 | ++ (void) shareLine : (NSString *) content withViewController:(UIViewController *)vc { | |
| 106 | +} | |
| 107 | + | |
| 108 | ++ (void) shareEmail : (NSString *) content withViewController:(UIViewController *)vc { | |
| 109 | +} | |
| 51 | 110 | @end |