summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-16 23:04:01 +0300
committerGravatar Vitaly Takmazov2018-10-16 23:04:01 +0300
commit842990ac65de6fd61e027c8a9cff48d30aaf3a60 (patch)
tree2150701f1c32ec69b9d254a4c96dedb0573737d5
parenta7cb4ab3f629b423099afad204c7ae1bf8df9677 (diff)
Content loading
-rw-r--r--Juick.xcodeproj/project.pbxproj10
-rw-r--r--Juick/Supporting Files/Juick-Prefix.pch1
-rw-r--r--Juick/ViewControllers/DiscoverViewController.m10
-rw-r--r--Juick/ViewControllers/MessagesViewController.m37
-rw-r--r--Juick/Views/ContentLoadingCell.h17
-rw-r--r--Juick/Views/ContentLoadingCell.m22
-rw-r--r--Juick/Views/ContentLoadingCell.xib84
-rw-r--r--Podfile1
-rw-r--r--Podfile.lock6
9 files changed, 172 insertions, 16 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj
index 0ae0559..e695258 100644
--- a/Juick.xcodeproj/project.pbxproj
+++ b/Juick.xcodeproj/project.pbxproj
@@ -33,6 +33,8 @@
77418CBD182FB9B6004111B7 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77418CBC182FB9B6004111B7 /* ImageIO.framework */; };
774528C21F930C06004D110B /* Attachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 774528C11F930C06004D110B /* Attachment.m */; };
774528C51F93AC0F004D110B /* CoreDataStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 774528C41F93AC0F004D110B /* CoreDataStack.m */; };
+ 7761133821766A3000D350CD /* ContentLoadingCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7761133621766A3000D350CD /* ContentLoadingCell.m */; };
+ 7761133921766A3000D350CD /* ContentLoadingCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7761133721766A3000D350CD /* ContentLoadingCell.xib */; };
776C41BD1FD3EF180063B82E /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41BB1FD3EF180063B82E /* MessageCell.m */; };
776C41BE1FD3EF180063B82E /* MessageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 776C41BC1FD3EF180063B82E /* MessageCell.xib */; };
776C41C11FD3FF6E0063B82E /* DiscoverViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41C01FD3FF6E0063B82E /* DiscoverViewController.m */; };
@@ -105,6 +107,9 @@
774528C91F93EE83004D110B /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
774528CB1F93EE9F004D110B /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
774528CD1F96B39C004D110B /* Juick.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Juick.entitlements; sourceTree = "<group>"; };
+ 7761133521766A3000D350CD /* ContentLoadingCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentLoadingCell.h; sourceTree = "<group>"; };
+ 7761133621766A3000D350CD /* ContentLoadingCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContentLoadingCell.m; sourceTree = "<group>"; };
+ 7761133721766A3000D350CD /* ContentLoadingCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ContentLoadingCell.xib; sourceTree = "<group>"; };
776C41BA1FD3EF180063B82E /* MessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = "<group>"; };
776C41BB1FD3EF180063B82E /* MessageCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageCell.m; sourceTree = "<group>"; };
776C41BC1FD3EF180063B82E /* MessageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageCell.xib; sourceTree = "<group>"; };
@@ -333,6 +338,9 @@
77B8B398207A52BD005CB20C /* MessageInputView.xib */,
77B8B39A207A5629005CB20C /* MessageInputView.h */,
77B8B39B207A5629005CB20C /* MessageInputView.m */,
+ 7761133521766A3000D350CD /* ContentLoadingCell.h */,
+ 7761133621766A3000D350CD /* ContentLoadingCell.m */,
+ 7761133721766A3000D350CD /* ContentLoadingCell.xib */,
);
path = Views;
sourceTree = "<group>";
@@ -419,6 +427,7 @@
77B8B399207A52BD005CB20C /* MessageInputView.xib in Resources */,
77C6ADDE1F770EB2000AEA8C /* Main.storyboard in Resources */,
773F23381F76ED5E00B5B0DF /* Splash@2x.png in Resources */,
+ 7761133921766A3000D350CD /* ContentLoadingCell.xib in Resources */,
776C41BE1FD3EF180063B82E /* MessageCell.xib in Resources */,
773F23371F76ED5E00B5B0DF /* Splash.png in Resources */,
773F231C1F76DD0B00B5B0DF /* SerpentineBoldItalic.ttf in Resources */,
@@ -482,6 +491,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 7761133821766A3000D350CD /* ContentLoadingCell.m in Sources */,
77E61A5E1FD4682B00B4E304 /* QuoteView.m in Sources */,
77317BBC181BBE8500D60005 /* AppDelegate.m in Sources */,
776C41C11FD3FF6E0063B82E /* DiscoverViewController.m in Sources */,
diff --git a/Juick/Supporting Files/Juick-Prefix.pch b/Juick/Supporting Files/Juick-Prefix.pch
index 0f3a8e7..2123166 100644
--- a/Juick/Supporting Files/Juick-Prefix.pch
+++ b/Juick/Supporting Files/Juick-Prefix.pch
@@ -27,4 +27,5 @@
#import <DateTools/DateTools.h>
#import <TagListView-ObjC/TagListView.h>
#import <PHFComposeBarView/PHFComposeBarView.h>
+ #import <UIView+Shimmer.h>
#endif
diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m
index 67036c6..b09e1df 100644
--- a/Juick/ViewControllers/DiscoverViewController.m
+++ b/Juick/ViewControllers/DiscoverViewController.m
@@ -56,9 +56,13 @@
[self performSegueWithIdentifier:@"threadViewSegue" sender:cell];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- MessageCell *cell = (MessageCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath];
- cell.delegate = self;
- return cell;
+ if (!self.dataLoading) {
+ MessageCell *cell = (MessageCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath];
+ cell.delegate = self;
+ return cell;
+ } else {
+ return [super tableView:tableView cellForRowAtIndexPath:indexPath];
+ }
}
-(void)avatarClicked:(NSString *)uname {
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m
index 957fce5..3fa6642 100644
--- a/Juick/ViewControllers/MessagesViewController.m
+++ b/Juick/ViewControllers/MessagesViewController.m
@@ -29,6 +29,9 @@
-(void) refreshData:(BOOL)scrollToBottom {
self.dataLoading = YES;
+ if (self.messages.count == 0) {
+ [self.tableView reloadData];
+ }
[[APIClient sharedClient] pullNextFromPath:self.path params:self.params callback:^(NSArray *next, NSError *err) {
NSArray *newMsgs = next;
if ([self isAtTop:self.params]) {
@@ -47,16 +50,19 @@
}
}
}
+ self.dataLoading = NO;
+ if (self.messages.count == 0) {
+ [self.tableView reloadData];
+ }
[self.messages addObjectsFromArray:newMsgs];
NSMutableArray *indexPaths = [NSMutableArray new];
for (NSUInteger index = oldCount; index <= oldCount + [newMsgs count] - 1; index++) {
[indexPaths addObject:[NSIndexPath indexPathForRow:index inSection: 0]];
}
[self.tableView beginUpdates];
- [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];
+ [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:NO];
[self.tableView endUpdates];
[self.refreshControl endRefreshing];
- self.dataLoading = NO;
if (scrollToBottom) {
NSIndexPath *lastRow = [NSIndexPath indexPathForRow:self.messages.count - 1 inSection:0];
[self.tableView scrollToRowAtIndexPath:lastRow atScrollPosition:UITableViewScrollPositionBottom animated:NO];
@@ -75,16 +81,15 @@
- (void)viewDidLoad
{
- [super viewDidLoad];
-
- self.dataLoading = NO;
+ self.dataLoading = YES;
[self.view setBackgroundColor:[ColorScheme mainBackground]];
[self.tableView registerNib:[UINib nibWithNibName:@"MessageCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"messageCell"];
+ [self.tableView registerNib:[UINib nibWithNibName:@"ContentLoadingCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"contentLoadingCell"];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 500.0f;
self.messages = [NSMutableArray array];
self.refreshControl = [UIRefreshControl new];
- [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
+ [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
}
- (void) composePressed {
@@ -96,15 +101,23 @@
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.messages.count;
+ return self.dataLoading && self.messages.count == 0 ? 4 : self.messages.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- Message *msg = [self.messages objectAtIndex:indexPath.row];
- NSString * cellIdentifier = @"messageCell";
- MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
- [cell configureWithMessage:msg];
- return cell;
+ if (self.dataLoading && self.messages.count == 0) {
+ return [tableView dequeueReusableCellWithIdentifier:@"contentLoadingCell"];
+ } else {
+ Message *msg = [self.messages objectAtIndex:indexPath.row];
+ NSString * cellIdentifier = @"messageCell";
+ MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
+ [cell configureWithMessage:msg];
+ return cell;
+ }
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+ return self.dataLoading && self.messages.count == 0 ? 200.0f : [super tableView:tableView heightForRowAtIndexPath:indexPath];
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView_ {
diff --git a/Juick/Views/ContentLoadingCell.h b/Juick/Views/ContentLoadingCell.h
new file mode 100644
index 0000000..d9a8f6f
--- /dev/null
+++ b/Juick/Views/ContentLoadingCell.h
@@ -0,0 +1,17 @@
+//
+// ContentLoadingCell.h
+// Juick
+//
+// Created by Vitaly Takmazov on 16/10/2018.
+// Copyright © 2018 com.juick. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ContentLoadingCell : UITableViewCell
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Juick/Views/ContentLoadingCell.m b/Juick/Views/ContentLoadingCell.m
new file mode 100644
index 0000000..5ec67b3
--- /dev/null
+++ b/Juick/Views/ContentLoadingCell.m
@@ -0,0 +1,22 @@
+//
+// ContentLoadingCell.m
+// Juick
+//
+// Created by Vitaly Takmazov on 16/10/2018.
+// Copyright © 2018 com.juick. All rights reserved.
+//
+
+#import "ContentLoadingCell.h"
+
+@implementation ContentLoadingCell
+
+- (void)awakeFromNib {
+ [super awakeFromNib];
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+ [super setSelected:selected animated:animated];
+ [self.contentView startShimmering];
+}
+
+@end
diff --git a/Juick/Views/ContentLoadingCell.xib b/Juick/Views/ContentLoadingCell.xib
new file mode 100644
index 0000000..e58af72
--- /dev/null
+++ b/Juick/Views/ContentLoadingCell.xib
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+ <device id="retina4_7" orientation="portrait">
+ <adaptation id="fullscreen"/>
+ </device>
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <objects>
+ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+ <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="contentLoadingCell" rowHeight="230" id="KGk-i7-Jjw" customClass="ContentLoadingCell">
+ <rect key="frame" x="0.0" y="0.0" width="310" height="230"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
+ <rect key="frame" x="0.0" y="0.0" width="310" height="229.5"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <stackView opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="751" axis="vertical" spacing="24" translatesAutoresizingMaskIntoConstraints="NO" id="33o-rP-dfk">
+ <rect key="frame" x="24" y="12" width="262" height="205.5"/>
+ <subviews>
+ <stackView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="255" verticalCompressionResistancePriority="748" alignment="center" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="Bqm-4Y-1yg">
+ <rect key="frame" x="0.0" y="0.0" width="262" height="48"/>
+ <subviews>
+ <view contentMode="scaleToFill" verticalCompressionResistancePriority="748" translatesAutoresizingMaskIntoConstraints="NO" id="Xfd-wK-nGQ">
+ <rect key="frame" x="0.0" y="0.0" width="48" height="48"/>
+ <color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ <constraints>
+ <constraint firstAttribute="height" constant="48" id="gWm-7q-ure"/>
+ <constraint firstAttribute="width" constant="48" id="paR-BH-BPq"/>
+ </constraints>
+ </view>
+ <view contentMode="scaleToFill" verticalCompressionResistancePriority="748" translatesAutoresizingMaskIntoConstraints="NO" id="RpL-2E-Dtt">
+ <rect key="frame" x="60" y="12" width="202" height="24"/>
+ <color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ <constraints>
+ <constraint firstAttribute="height" constant="24" id="jxf-Sb-SeH"/>
+ </constraints>
+ </view>
+ </subviews>
+ </stackView>
+ <stackView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="249" verticalCompressionResistancePriority="752" axis="vertical" distribution="fillEqually" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="WY4-IV-5wO">
+ <rect key="frame" x="0.0" y="72" width="262" height="133.5"/>
+ <subviews>
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TF4-pH-jy5">
+ <rect key="frame" x="0.0" y="0.0" width="262" height="17"/>
+ <color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </view>
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iLC-oW-h16">
+ <rect key="frame" x="0.0" y="29" width="262" height="17"/>
+ <color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </view>
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="e26-WV-V2J">
+ <rect key="frame" x="0.0" y="58" width="262" height="17.5"/>
+ <color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </view>
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5HE-g4-DHe">
+ <rect key="frame" x="0.0" y="87.5" width="262" height="17"/>
+ <color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </view>
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="O0R-kH-hzS">
+ <rect key="frame" x="0.0" y="116.5" width="262" height="17"/>
+ <color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </view>
+ </subviews>
+ </stackView>
+ </subviews>
+ </stackView>
+ </subviews>
+ <constraints>
+ <constraint firstItem="33o-rP-dfk" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="Fdp-wO-B2U"/>
+ <constraint firstAttribute="bottom" secondItem="33o-rP-dfk" secondAttribute="bottom" constant="12" id="PBl-xt-lLN"/>
+ <constraint firstAttribute="trailing" secondItem="33o-rP-dfk" secondAttribute="trailing" constant="24" id="kae-JF-BnF"/>
+ <constraint firstItem="33o-rP-dfk" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="24" id="oli-Q3-Y7U"/>
+ </constraints>
+ </tableViewCellContentView>
+ <viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
+ <point key="canvasLocation" x="139.19999999999999" y="226.6866566716642"/>
+ </tableViewCell>
+ </objects>
+</document>
diff --git a/Podfile b/Podfile
index d223931..61ba285 100644
--- a/Podfile
+++ b/Podfile
@@ -10,5 +10,6 @@ target "Juick" do
pod 'DateTools'
pod 'TagListView-ObjC'
pod 'PHFComposeBarView'
+ pod 'UIView+Shimmer'
end
diff --git a/Podfile.lock b/Podfile.lock
index b4a9307..a43be6b 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -30,6 +30,7 @@ PODS:
- PHFDelegateChain (1.0.1)
- TagListView-ObjC (0.1.1)
- TTTAttributedLabel (2.0.0)
+ - "UIView+Shimmer (1.0.0)"
- YYModel (1.0.4)
DEPENDENCIES:
@@ -40,6 +41,7 @@ DEPENDENCIES:
- PHFComposeBarView
- TagListView-ObjC
- TTTAttributedLabel
+ - "UIView+Shimmer"
- YYModel
SPEC REPOS:
@@ -52,6 +54,7 @@ SPEC REPOS:
- PHFDelegateChain
- TagListView-ObjC
- TTTAttributedLabel
+ - "UIView+Shimmer"
- YYModel
SPEC CHECKSUMS:
@@ -63,8 +66,9 @@ SPEC CHECKSUMS:
PHFDelegateChain: 491f9cd8a3fb8761f390ff05f74a0e168d48d285
TagListView-ObjC: 432991e24c5177eb4fa7d721de7084f09f39a0b8
TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656
+ "UIView+Shimmer": ed634f95e8f4bda666b28b47bd85a4336a4117d8
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
-PODFILE CHECKSUM: a4dae3ca80591a5eedeac58df020463fdd94bb0e
+PODFILE CHECKSUM: 4e2ec6ba0e314243295aab124ee21ea241447fd8
COCOAPODS: 1.5.3