diff --git a/Ash_AWord.xcodeproj/project.pbxproj b/Ash_AWord.xcodeproj/project.pbxproj index f6e2dff..7065801 100644 --- a/Ash_AWord.xcodeproj/project.pbxproj +++ b/Ash_AWord.xcodeproj/project.pbxproj @@ -95,6 +95,7 @@ A968627A1ACCF13300DDAA6B /* PSTGridLayoutSection.m in Sources */ = {isa = PBXBuildFile; fileRef = A968626D1ACCF13300DDAA6B /* PSTGridLayoutSection.m */; }; A968627C1ACCF3D200DDAA6B /* cellmorebtnnormalN@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A968627B1ACCF3D200DDAA6B /* cellmorebtnnormalN@2x.png */; }; A968627E1ACCF46E00DDAA6B /* cellmorebtnclickN@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A968627D1ACCF46E00DDAA6B /* cellmorebtnclickN@2x.png */; }; + A96D2F261B2FFDA300DC0284 /* DejalActivityView.m in Sources */ = {isa = PBXBuildFile; fileRef = A96D2F251B2FFDA300DC0284 /* DejalActivityView.m */; }; A96F27EE1B2195BA00DA0A66 /* UIImageView+Reloading.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F27ED1B2195BA00DA0A66 /* UIImageView+Reloading.m */; }; A96F27F41B21C5AC00DA0A66 /* PraiseUserListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F27F21B21C5AC00DA0A66 /* PraiseUserListTableViewCell.m */; }; A96F27F51B21C5AC00DA0A66 /* PraiseUserListTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A96F27F31B21C5AC00DA0A66 /* PraiseUserListTableViewCell.xib */; }; @@ -372,6 +373,8 @@ A968626D1ACCF13300DDAA6B /* PSTGridLayoutSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSTGridLayoutSection.m; sourceTree = ""; }; A968627B1ACCF3D200DDAA6B /* cellmorebtnnormalN@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "cellmorebtnnormalN@2x.png"; sourceTree = ""; }; A968627D1ACCF46E00DDAA6B /* cellmorebtnclickN@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "cellmorebtnclickN@2x.png"; sourceTree = ""; }; + A96D2F241B2FFDA300DC0284 /* DejalActivityView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DejalActivityView.h; sourceTree = ""; }; + A96D2F251B2FFDA300DC0284 /* DejalActivityView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DejalActivityView.m; sourceTree = ""; }; A96F27EC1B2195BA00DA0A66 /* UIImageView+Reloading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+Reloading.h"; sourceTree = ""; }; A96F27ED1B2195BA00DA0A66 /* UIImageView+Reloading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+Reloading.m"; sourceTree = ""; }; A96F27F11B21C5AC00DA0A66 /* PraiseUserListTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PraiseUserListTableViewCell.h; sourceTree = ""; }; @@ -816,6 +819,15 @@ path = PSTCollectionView; sourceTree = ""; }; + A96D2F231B2FFD9C00DC0284 /* DejalActivityView */ = { + isa = PBXGroup; + children = ( + A96D2F241B2FFDA300DC0284 /* DejalActivityView.h */, + A96D2F251B2FFDA300DC0284 /* DejalActivityView.m */, + ); + path = DejalActivityView; + sourceTree = ""; + }; A96F27EF1B21B98900DA0A66 /* User */ = { isa = PBXGroup; children = ( @@ -1005,6 +1017,7 @@ A97C54D91AC9014D0038818A /* Vender */ = { isa = PBXGroup; children = ( + A96D2F231B2FFD9C00DC0284 /* DejalActivityView */, A9A3A7551B281392001AAB3A /* CExpandHeader */, A9754A0D1ADC080E0018BAAD /* AudioPlayer */, A96862511ACCF13300DDAA6B /* PSTCollectionView */, @@ -1614,6 +1627,7 @@ A97559B21ACBC683004ADA42 /* NotePublishViewController.m in Sources */, A9754A1F1ADC080E0018BAAD /* DataSource.m in Sources */, A97C54DD1AC901980038818A /* MBProgressHUD+Util.m in Sources */, + A96D2F261B2FFDA300DC0284 /* DejalActivityView.m in Sources */, A96862721ACCF13300DDAA6B /* PSTCollectionViewData.m in Sources */, A97DBE331ACAE10800705682 /* LoginViewController.m in Sources */, A98536721AEB66F9000312BF /* ReportViewController.m in Sources */, diff --git a/Ash_AWord.xcworkspace/xcuserdata/xmfish.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Ash_AWord.xcworkspace/xcuserdata/xmfish.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 9cfafa6..be2ee33 100644 --- a/Ash_AWord.xcworkspace/xcuserdata/xmfish.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Ash_AWord.xcworkspace/xcuserdata/xmfish.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -154,11 +154,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/ViewModels/Note/NoteViewModel.m" - timestampString = "449799647.215245" + timestampString = "456067903.226223" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "37" - endingLineNumber = "37" + startingLineNumber = "38" + endingLineNumber = "38" landmarkName = "-initWithDictionary:error:" landmarkType = "5"> @@ -410,11 +410,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/ViewModels/Note/NoteViewModel.m" - timestampString = "449802115.789683" + timestampString = "456067903.226223" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "36" - endingLineNumber = "36" + startingLineNumber = "37" + endingLineNumber = "37" landmarkName = "-initWithDictionary:error:" landmarkType = "5"> @@ -610,22 +610,6 @@ - - - - @@ -2073,11 +2057,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/ViewModels/Note/NoteViewModel.m" - timestampString = "455773044.376916" + timestampString = "456067903.226223" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "92" - endingLineNumber = "92" + startingLineNumber = "93" + endingLineNumber = "93" landmarkName = "+requireOhterWithOrder_by:withPage:withPage_size:withOtherId:" landmarkType = "5"> @@ -2089,11 +2073,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/ViewModels/Note/NoteViewModel.m" - timestampString = "455774684.961607" + timestampString = "456067903.226223" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "151" - endingLineNumber = "151" + startingLineNumber = "152" + endingLineNumber = "152" landmarkName = "+requireDelWithRecordId:" landmarkType = "5"> @@ -2105,11 +2089,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/Views/User/PersonalTopView.m" - timestampString = "455781096.07119" + timestampString = "456128789.948155" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "64" - endingLineNumber = "64" + startingLineNumber = "79" + endingLineNumber = "79" landmarkName = "-imageBtnClick:" landmarkType = "5"> @@ -2121,11 +2105,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/Views/User/PersonalTopView.m" - timestampString = "455781110.142847" + timestampString = "456128789.948155" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "47" - endingLineNumber = "47" + startingLineNumber = "62" + endingLineNumber = "62" landmarkName = "-voiceBtnClick:" landmarkType = "5"> @@ -2153,11 +2137,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/Views/User/PersonalTopView.m" - timestampString = "455781242.45944" + timestampString = "456128789.948155" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "44" - endingLineNumber = "44" + startingLineNumber = "59" + endingLineNumber = "59" landmarkName = "-avatarBtnClick:" landmarkType = "5"> @@ -2169,11 +2153,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/Views/User/PersonalTopView.m" - timestampString = "455781573.755644" + timestampString = "456128789.948155" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "80" - endingLineNumber = "80" + startingLineNumber = "95" + endingLineNumber = "95" landmarkName = "-attentionBtnClick:" landmarkType = "5"> @@ -2293,7 +2277,7 @@ @@ -2409,11 +2393,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/ViewControllers/Note/NoteCommentViewController.m" - timestampString = "456033875.922867" + timestampString = "456067283.82546" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "228" - endingLineNumber = "228" + startingLineNumber = "231" + endingLineNumber = "231" landmarkName = "-tableView:didSelectRowAtIndexPath:" landmarkType = "5"> @@ -2425,11 +2409,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/Views/Common/CommentTableViewCell.m" - timestampString = "456034084.470231" + timestampString = "456068317.847602" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "49" - endingLineNumber = "49" + startingLineNumber = "66" + endingLineNumber = "66" landmarkName = "-setCommentInfoViewModel:" landmarkType = "5"> @@ -2441,11 +2425,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Ash_AWord/ViewControllers/Note/NoteCommentViewController.m" - timestampString = "456034106.040482" + timestampString = "456067283.82546" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "221" - endingLineNumber = "221" + startingLineNumber = "222" + endingLineNumber = "222" landmarkName = "-tableView:cellForRowAtIndexPath:" landmarkType = "5"> @@ -2453,7 +2437,7 @@ + + + + + + + + + + + + + + + + diff --git a/Ash_AWord/Config/Common.h b/Ash_AWord/Config/Common.h index 969e174..05bb32d 100644 --- a/Ash_AWord/Config/Common.h +++ b/Ash_AWord/Config/Common.h @@ -57,6 +57,7 @@ #define kNetworkErrorTips @"网络连接失败" #define kSSoErrorTips @"授权失败,请重新授权" #define kLoginTips @"登录中" +#define kLoadingTips @"加载中。。。" /** * 接口地址 */ diff --git a/Ash_AWord/PrefixHeader.pch b/Ash_AWord/PrefixHeader.pch index ecd9dac..aae7e3c 100644 --- a/Ash_AWord/PrefixHeader.pch +++ b/Ash_AWord/PrefixHeader.pch @@ -39,6 +39,7 @@ #import "MobClick.h" #import "LoginViewController.h" #import "UIImageView+Reloading.h" +#import "DejalActivityView.h" #endif #endif diff --git a/Ash_AWord/Utility/Tool/Ash_UIUtil.m b/Ash_AWord/Utility/Tool/Ash_UIUtil.m index b4748b3..8412a23 100644 --- a/Ash_AWord/Utility/Tool/Ash_UIUtil.m +++ b/Ash_AWord/Utility/Tool/Ash_UIUtil.m @@ -418,7 +418,7 @@ } +(NSDictionary*)getHtmlDicWithFontSize:(NSInteger)fontSize { - NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentLeft],DTDefaultTextAlignment,[UIColor blackColor],DTDefaultTextColor,[NSNumber numberWithInteger:fontSize], DTDefaultFontSize,[[UIFont appFontOfSize:1] fontName],DTDefaultFontName,[UIColor appMainColor],DTDefaultLinkColor, nil]; + NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentLeft],DTDefaultTextAlignment,[UIColor blackColor],DTDefaultTextColor,[NSNumber numberWithInteger:fontSize], DTDefaultFontSize,[[UIFont appFontOfSize:1] fontName],DTDefaultFontName,[UIColor appMainColor],DTDefaultLinkColor,[NSNumber numberWithBool:NO], DTDefaultLinkDecoration, nil]; return optionsDic; } @end diff --git a/Ash_AWord/Vender/DejalActivityView/DejalActivityView.h b/Ash_AWord/Vender/DejalActivityView/DejalActivityView.h new file mode 100755 index 0000000..d4e5b2d --- /dev/null +++ b/Ash_AWord/Vender/DejalActivityView/DejalActivityView.h @@ -0,0 +1,141 @@ +// +// DejalActivityView.h +// Dejal Open Source +// +// Created by David Sinclair on 2009-07-26. +// Copyright (c) 2009-2012 Dejal Systems, LLC. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#import + + +@interface DejalActivityView : UIView + +// The view to contain the activity indicator and label. The bezel style has a semi-transparent rounded rectangle, others are fully transparent: +@property (nonatomic, strong, readonly) UIView *borderView; + +// The activity indicator view: +@property (nonatomic, strong, readonly) UIActivityIndicatorView *activityIndicator; + +// The activity label: +@property (nonatomic, strong, readonly) UILabel *activityLabel; + +// A fixed width for the label text, or zero to automatically calculate the text size (normally set on creation of the view object): +@property (nonatomic) NSUInteger labelWidth; + +// Whether to show the network activity indicator in the status bar. Set to YES if the activity is network-related. This can be toggled on and off as desired while the activity view is visible (e.g. have it on while fetching data, then disable it while parsing it). By default it is not shown: +@property (nonatomic) BOOL showNetworkActivityIndicator; + +// Returns the currently displayed activity view, or nil if there isn't one: ++ (DejalActivityView *)currentActivityView; + +// Creates and adds an activity view centered within the specified view, using the label "Loading...". Returns the activity view, already added as a subview of the specified view: ++ (DejalActivityView *)activityViewForView:(UIView *)addToView; + +// Creates and adds an activity view centered within the specified view, using the specified label. Returns the activity view, already added as a subview of the specified view: ++ (DejalActivityView *)activityViewForView:(UIView *)addToView withLabel:(NSString *)labelText; + +// Creates and adds an activity view centered within the specified view, using the specified label and a fixed label width. The fixed width is useful if you want to change the label text while the view is visible. Returns the activity view, already added as a subview of the specified view: ++ (DejalActivityView *)activityViewForView:(UIView *)addToView withLabel:(NSString *)labelText width:(NSUInteger)aLabelWidth; + +// Designated initializer. Configures the activity view using the specified label text and width, and adds as a subview of the specified view: +- (DejalActivityView *)initForView:(UIView *)addToView withLabel:(NSString *)labelText width:(NSUInteger)aLabelWidth; + +// Immediately removes and releases the view without any animation: ++ (void)removeView; + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +// These methods are exposed for subclasses to override to customize the appearance and behavior; see the implementation for details: + +@interface DejalActivityView () + +- (UIView *)viewForView:(UIView *)view; +- (CGRect)enclosingFrame; +- (void)setupBackground; +- (UIView *)makeBorderView; +- (UIActivityIndicatorView *)makeActivityIndicator; +- (UILabel *)makeActivityLabelWithText:(NSString *)labelText; +- (void)animateShow; +- (void)animateRemove; + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@interface DejalWhiteActivityView : DejalActivityView + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@interface DejalBezelActivityView : DejalActivityView + +// Animates the view out from the superview and releases it, or simply removes and releases it immediately if not animating: ++ (void)removeViewAnimated:(BOOL)animated; + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@interface DejalKeyboardActivityView : DejalBezelActivityView + +// Creates and adds a keyboard-style activity view, using the label "Loading...". Returns the activity view, already covering the keyboard, or nil if the keyboard isn't currently displayed: ++ (DejalKeyboardActivityView *)activityView; + +// Creates and adds a keyboard-style activity view, using the specified label. Returns the activity view, already covering the keyboard, or nil if the keyboard isn't currently displayed: ++ (DejalKeyboardActivityView *)activityViewWithLabel:(NSString *)labelText; + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@interface UIApplication (KeyboardView) + +- (UIView *)keyboardView; + +@end; + diff --git a/Ash_AWord/Vender/DejalActivityView/DejalActivityView.m b/Ash_AWord/Vender/DejalActivityView/DejalActivityView.m new file mode 100755 index 0000000..f55de11 --- /dev/null +++ b/Ash_AWord/Vender/DejalActivityView/DejalActivityView.m @@ -0,0 +1,845 @@ +// +// DejalActivityView.m +// Dejal Open Source +// +// Created by David Sinclair on 2009-07-26. +// Copyright (c) 2009-2012 Dejal Systems, LLC. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Credit: inspired by Matt Gallagher's LoadingView blog post: +// http://cocoawithlove.com/2009/04/showing-message-over-iphone-keyboard.html +// + + +#import "DejalActivityView.h" +#import + + +@interface DejalActivityView () + +@property (nonatomic, strong) UIView *originalView; +@property (nonatomic, strong) UIView *borderView; +@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator; +@property (nonatomic, strong) UILabel *activityLabel; + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@implementation DejalActivityView + +@synthesize originalView, borderView, activityIndicator, activityLabel, labelWidth, showNetworkActivityIndicator; + +static DejalActivityView *dejalActivityView = nil; + +/* + currentActivityView + + Returns the currently displayed activity view, or nil if there isn't one. + + Written by DJS 2009-07. +*/ + ++ (DejalActivityView *)currentActivityView; +{ + return dejalActivityView; +} + +/* + activityViewForView: + + Creates and adds an activity view centered within the specified view, using the label "Loading...". Returns the activity view, already added as a subview of the specified view. + + Written by DJS 2009-07. + Changed by DJS 2010-06 to add "new" prefix to the method name to make it clearer that this returns a retained object. + Changed by DJS 2011-08 to remove the "new" prefix again. +*/ + ++ (DejalActivityView *)activityViewForView:(UIView *)addToView; +{ + return [self activityViewForView:addToView withLabel:NSLocalizedString(@"Loading...", @"Default DejalActivtyView label text") width:0]; +} + +/* + activityViewForView:withLabel: + + Creates and adds an activity view centered within the specified view, using the specified label. Returns the activity view, already added as a subview of the specified view. + + Written by DJS 2009-07. + Changed by DJS 2010-06 to add "new" prefix to the method name to make it clearer that this returns a retained object. + Changed by DJS 2011-08 to remove the "new" prefix again. +*/ + ++ (DejalActivityView *)activityViewForView:(UIView *)addToView withLabel:(NSString *)labelText; +{ + return [self activityViewForView:addToView withLabel:labelText width:0]; +} + +/* + activityViewForView:withLabel:width: + + Creates and adds an activity view centered within the specified view, using the specified label and a fixed label width. The fixed width is useful if you want to change the label text while the view is visible. Returns the activity view, already added as a subview of the specified view. + + Written by DJS 2009-07. + Changed by DJS 2010-06 to add "new" prefix to the method name to make it clearer that this returns a retained object. + Changed by DJS 2011-08 to remove the "new" prefix again, and move the singleton stuff to here. +*/ + ++ (DejalActivityView *)activityViewForView:(UIView *)addToView withLabel:(NSString *)labelText width:(NSUInteger)aLabelWidth; +{ + // Immediately remove any existing activity view: + if (dejalActivityView) + [self removeView]; + + // Remember the new view (so this is a singleton): + dejalActivityView = [[self alloc] initForView:addToView withLabel:labelText width:aLabelWidth]; + + return dejalActivityView; +} + +/* + initForView:withLabel:width: + + Designated initializer. Configures the activity view using the specified label text and width, and adds as a subview of the specified view. + + Written by DJS 2009-07. + Changed by DJS 2011-08 to move the singleton stuff to the calling class method, where it should be. +*/ + +- (DejalActivityView *)initForView:(UIView *)addToView withLabel:(NSString *)labelText width:(NSUInteger)aLabelWidth; +{ + if (!(self = [super initWithFrame:CGRectZero])) + return nil; + + // Allow subclasses to change the view to which to add the activity view (e.g. to cover the keyboard): + self.originalView = addToView; + addToView = [self viewForView:addToView]; + + // Configure this view (the background) and its subviews: + [self setupBackground]; + self.labelWidth = aLabelWidth; + self.borderView = [self makeBorderView]; + self.activityIndicator = [self makeActivityIndicator]; + self.activityLabel = [self makeActivityLabelWithText:labelText]; + + // Assemble the subviews: + [addToView addSubview:self]; + [self addSubview:self.borderView]; + [self.borderView addSubview:self.activityIndicator]; + [self.borderView addSubview:self.activityLabel]; + + // Animate the view in, if appropriate: + [self animateShow]; + + return self; +} + +- (void)dealloc; +{ + if ([dejalActivityView isEqual:self]) + dejalActivityView = nil; +} + +/* + removeView + + Immediately removes and releases the view without any animation. + + Written by DJS 2009-07. + Changed by DJS 2009-09 to disable the network activity indicator if it was shown by this view. +*/ + ++ (void)removeView; +{ + if (!dejalActivityView) + return; + + if (dejalActivityView.showNetworkActivityIndicator) + [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; + + [dejalActivityView removeFromSuperview]; + + // Remove the global reference: + dejalActivityView = nil; +} + +/* + viewForView: + + Returns the view to which to add the activity view. By default returns the same view. Subclasses may override this to change the view. + + Written by DJS 2009-07. +*/ + +- (UIView *)viewForView:(UIView *)view; +{ + return view; +} + +/* + enclosingFrame + + Returns the frame to use for the activity view. Defaults to the superview's bounds. Subclasses may override this to use something different, if desired. + + Written by DJS 2009-07. +*/ + +- (CGRect)enclosingFrame; +{ + return self.superview.bounds; +} + +/* + setupBackground + + Configure the background of the activity view. + + Written by DJS 2009-07. +*/ + +- (void)setupBackground; +{ + self.opaque = NO; + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; +} + +/* + makeBorderView + + Returns a new view to contain the activity indicator and label. By default this view is transparent. Subclasses may override this method, optionally calling super, to use a different or customized view. + + Written by DJS 2009-07. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UIView *)makeBorderView; +{ + UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; + + view.opaque = NO; + view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; + + return view; +} + +/* + makeActivityIndicator + + Returns a new activity indicator view. Subclasses may override this method, optionally calling super, to use a different or customized view. + + Written by DJS 2009-07. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UIActivityIndicatorView *)makeActivityIndicator; +{ + UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + + [indicator startAnimating]; + + return indicator; +} + +/* + makeActivityLabelWithText: + + Returns a new activity label. Subclasses may override this method, optionally calling super, to use a different or customized view. + + Written by DJS 2009-07. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UILabel *)makeActivityLabelWithText:(NSString *)labelText; +{ + UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; + + label.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; + label.textAlignment = UITextAlignmentLeft; + label.textColor = [UIColor blackColor]; + label.backgroundColor = [UIColor clearColor]; + label.shadowColor = [UIColor whiteColor]; + label.shadowOffset = CGSizeMake(0.0, 1.0); + label.text = labelText; + + return label; +} + +/* + layoutSubviews + + Positions and sizes the various views that make up the activity view, including after rotation. + + Written by DJS 2009-07. +*/ + +- (void)layoutSubviews; +{ + self.frame = [self enclosingFrame]; + + // If we're animating a transform, don't lay out now, as can't use the frame property when transforming: + if (!CGAffineTransformIsIdentity(self.borderView.transform)) + return; + + CGSize textSize = [self.activityLabel.text sizeWithFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]]; + + // Use the fixed width if one is specified: + if (self.labelWidth > 10) + textSize.width = self.labelWidth; + + self.activityLabel.frame = CGRectMake(self.activityLabel.frame.origin.x, self.activityLabel.frame.origin.y, textSize.width, textSize.height); + + // Calculate the size and position for the border view: with the indicator to the left of the label, and centered in the receiver: + CGRect borderFrame = CGRectZero; + borderFrame.size.width = self.activityIndicator.frame.size.width + textSize.width + 25.0; + borderFrame.size.height = self.activityIndicator.frame.size.height + 10.0; + borderFrame.origin.x = floor(0.5 * (self.frame.size.width - borderFrame.size.width)); + borderFrame.origin.y = floor(0.5 * (self.frame.size.height - borderFrame.size.height - 20.0)); + self.borderView.frame = borderFrame; + + // Calculate the position of the indicator: vertically centered and at the left of the border view: + CGRect indicatorFrame = self.activityIndicator.frame; + indicatorFrame.origin.x = 10.0; + indicatorFrame.origin.y = 0.5 * (borderFrame.size.height - indicatorFrame.size.height); + self.activityIndicator.frame = indicatorFrame; + + // Calculate the position of the label: vertically centered and at the right of the border view: + CGRect labelFrame = self.activityLabel.frame; + labelFrame.origin.x = borderFrame.size.width - labelFrame.size.width - 10.0; + labelFrame.origin.y = floor(0.5 * (borderFrame.size.height - labelFrame.size.height)); + self.activityLabel.frame = labelFrame; +} + +/* + animateShow + + Animates the view into visibility. Does nothing for the simple activity view. + + Written by DJS 2009-07. +*/ + +- (void)animateShow; +{ + // Does nothing by default +} + +/* + animateRemove + + Animates the view out of visibiltiy. Does nothng for the simple activity view. + + Written by DJS 2009-07. +*/ + +- (void)animateRemove; +{ + // Does nothing by default +} + +/* + setShowNetworkActivityIndicator: + + Sets whether or not to show the network activity indicator in the status bar. Set to YES if the activity is network-related. This can be toggled on and off as desired while the activity view is visible (e.g. have it on while fetching data, then disable it while parsing it). By default it is not shown. + + Written by DJS 2009-09. +*/ + +- (void)setShowNetworkActivityIndicator:(BOOL)show; +{ + showNetworkActivityIndicator = show; + + [UIApplication sharedApplication].networkActivityIndicatorVisible = show; +} + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@implementation DejalWhiteActivityView + +/* + makeActivityIndicator + + Returns a new activity indicator view. This subclass uses a white activity indicator instead of gray. + + Written by DJS 2009-10. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UIActivityIndicatorView *)makeActivityIndicator; +{ + UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; + + [indicator startAnimating]; + + return indicator; +} + +/* + makeActivityLabelWithText: + + Returns a new activity label. This subclass uses white text instead of black. + + Written by DJS 2009-10. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UILabel *)makeActivityLabelWithText:(NSString *)labelText; +{ + UILabel *label = [super makeActivityLabelWithText:labelText]; + + label.textColor = [UIColor whiteColor]; + label.shadowColor = [UIColor blackColor]; + + return label; +} + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@implementation DejalBezelActivityView + +/* + viewForView: + + Returns the view to which to add the activity view. For the bezel style, if there is a keyboard displayed, the view is changed to the keyboard's superview. + + Written by DJS 2009-07. +*/ + +- (UIView *)viewForView:(UIView *)view; +{ + UIView *keyboardView = [[UIApplication sharedApplication] keyboardView]; + + if (keyboardView) + view = keyboardView.superview; + + return view; +} + +/* + enclosingFrame + + Returns the frame to use for the activity view. For the bezel style, if there is a keyboard displayed, the frame is changed to cover the keyboard too. + + Written by DJS 2009-07. +*/ + +- (CGRect)enclosingFrame; +{ + CGRect frame = [super enclosingFrame]; + + if (self.superview != self.originalView) + frame = [self.originalView convertRect:self.originalView.bounds toView:self.superview]; + + return frame; +} + +/* + setupBackground + + Configure the background of the activity view. + + Written by DJS 2009-07. +*/ + +- (void)setupBackground; +{ + [super setupBackground]; + + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.35]; +} + +/* + makeBorderView + + Returns a new view to contain the activity indicator and label. The bezel style has a semi-transparent rounded rectangle. + + Written by DJS 2009-07. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UIView *)makeBorderView; +{ + UIView *view = [super makeBorderView]; + + view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5]; + view.layer.cornerRadius = 10.0; + + return view; +} + +/* + makeActivityIndicator + + Returns a new activity indicator view. The bezel style uses a large white indicator. + + Written by DJS 2009-07. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UIActivityIndicatorView *)makeActivityIndicator; +{ + UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + + [indicator startAnimating]; + + return indicator; +} + +/* + makeActivityLabelWithText: + + Returns a new activity label. The bezel style uses centered white text. + + Written by DJS 2009-07. + Changed by Suleman Sidat 2011-07 to support a multi-line label. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UILabel *)makeActivityLabelWithText:(NSString *)labelText; +{ + UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; + + label.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; + label.textAlignment = UITextAlignmentCenter; + label.textColor = [UIColor whiteColor]; + label.backgroundColor = [UIColor clearColor]; + label.numberOfLines = 0; + label.lineBreakMode = UILineBreakModeWordWrap; + label.text = labelText; + + return label; +} + +/* + layoutSubviews + + Positions and sizes the various views that make up the activity view, including after rotation. + + Written by DJS 2009-07. + Changed by Suleman Sidat 2011-07 to support a multi-line label. +*/ + +- (void)layoutSubviews; +{ + // If we're animating a transform, don't lay out now, as can't use the frame property when transforming: + if (!CGAffineTransformIsIdentity(self.borderView.transform)) + return; + + self.frame = [self enclosingFrame]; + + CGSize maxSize = CGSizeMake(260, 400); + CGSize textSize = [self.activityLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:[UIFont systemFontSize]] constrainedToSize:maxSize lineBreakMode:self.activityLabel.lineBreakMode]; + + // Use the fixed width if one is specified: + if (self.labelWidth > 10) + textSize.width = self.labelWidth; + + // Require that the label be at least as wide as the indicator, since that width is used for the border view: + if (textSize.width < self.activityIndicator.frame.size.width) + textSize.width = self.activityIndicator.frame.size.width + 10.0; + + // If there's no label text, don't need to allow height for it: + if (self.activityLabel.text.length == 0) + textSize.height = 0.0; + + self.activityLabel.frame = CGRectMake(self.activityLabel.frame.origin.x, self.activityLabel.frame.origin.y, textSize.width, textSize.height); + + // Calculate the size and position for the border view: with the indicator vertically above the label, and centered in the receiver: + CGRect borderFrame = CGRectZero; + borderFrame.size.width = textSize.width + 30.0; + borderFrame.size.height = self.activityIndicator.frame.size.height + textSize.height + 40.0; + borderFrame.origin.x = floor(0.5 * (self.frame.size.width - borderFrame.size.width)); + borderFrame.origin.y = floor(0.5 * (self.frame.size.height - borderFrame.size.height)); + self.borderView.frame = borderFrame; + + // Calculate the position of the indicator: horizontally centered and near the top of the border view: + CGRect indicatorFrame = self.activityIndicator.frame; + indicatorFrame.origin.x = 0.5 * (borderFrame.size.width - indicatorFrame.size.width); + indicatorFrame.origin.y = 20.0; + self.activityIndicator.frame = indicatorFrame; + + // Calculate the position of the label: horizontally centered and near the bottom of the border view: + CGRect labelFrame = self.activityLabel.frame; + labelFrame.origin.x = floor(0.5 * (borderFrame.size.width - labelFrame.size.width)); + labelFrame.origin.y = borderFrame.size.height - labelFrame.size.height - 10.0; + self.activityLabel.frame = labelFrame; +} + +/* + animateShow + + Animates the view into visibility. For the bezel style, fades in the background and zooms the bezel down from a large size. + + Written by DJS 2009-07. +*/ + +- (void)animateShow; +{ + self.alpha = 0.0; + self.borderView.transform = CGAffineTransformMakeScale(3.0, 3.0); + + [UIView beginAnimations:nil context:nil]; +// [UIView setAnimationDuration:5.0]; // Uncomment to see the animation in slow motion + + self.borderView.transform = CGAffineTransformIdentity; + self.alpha = 1.0; + + [UIView commitAnimations]; +} + +/* + animateRemove + + Animates the view out, deferring the removal until the animation is complete. For the bezel style, fades out the background and zooms the bezel down to half size. + + Written by DJS 2009-07. + Changed by DJS 2009-09 to disable the network activity indicator if it was shown by this view. +*/ + +- (void)animateRemove; +{ + if (self.showNetworkActivityIndicator) + [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; + + self.borderView.transform = CGAffineTransformIdentity; + + [UIView beginAnimations:nil context:nil]; +// [UIView setAnimationDuration:5.0]; // Uncomment to see the animation in slow motion + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(removeAnimationDidStop:finished:context:)]; + + self.borderView.transform = CGAffineTransformMakeScale(0.5, 0.5); + self.alpha = 0.0; + + [UIView commitAnimations]; +} + +- (void)removeAnimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context; +{ + [[self class] removeView]; +} + +/* + removeViewAnimated: + + Animates the view out from the superview and releases it, or simply removes and releases it immediately if not animating. + + Written by DJS 2009-07. +*/ + ++ (void)removeViewAnimated:(BOOL)animated; +{ + if (!dejalActivityView) + return; + + if (animated) + [dejalActivityView animateRemove]; + else + [[self class] removeView]; +} + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@implementation DejalKeyboardActivityView + +/* + activityView + + Creates and adds a keyboard-style activity view, using the label "Loading...". Returns the activity view, already covering the keyboard, or nil if the keyboard isn't currently displayed. + + Written by DJS 2009-07. + Changed by DJS 2010-06 to add "new" prefix to the method name to make it clearer that this returns a retained object. + Changed by DJS 2011-08 to remove the "new" prefix again. +*/ + ++ (DejalKeyboardActivityView *)activityView; +{ + return [self activityViewWithLabel:NSLocalizedString(@"Loading...", @"Default DejalActivtyView label text")]; +} + +/* + activityViewWithLabel: + + Creates and adds a keyboard-style activity view, using the specified label. Returns the activity view, already covering the keyboard, or nil if the keyboard isn't currently displayed. + + Written by DJS 2009-07. + Changed by DJS 2010-06 to add "new" prefix to the method name to make it clearer that this returns a retained object. + Changed by DJS 2011-08 to remove the "new" prefix again. +*/ + ++ (DejalKeyboardActivityView *)activityViewWithLabel:(NSString *)labelText; +{ + UIView *keyboardView = [[UIApplication sharedApplication] keyboardView]; + + if (!keyboardView) + return nil; + else + return (DejalKeyboardActivityView *)[self activityViewForView:keyboardView withLabel:labelText]; +} + +/* + viewForView: + + Returns the view to which to add the activity view. For the keyboard style, returns the same view (which will already be the keyboard). + + Written by DJS 2009-07. +*/ + +- (UIView *)viewForView:(UIView *)view; +{ + return view; +} + +/* + animateShow + + Animates the view into visibility. For the keyboard style, simply fades in. + + Written by DJS 2009-07. +*/ + +- (void)animateShow; +{ + self.alpha = 0.0; + + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:1.0]; + + self.alpha = 1.0; + + [UIView commitAnimations]; +} + +/* + animateRemove + + Animates the view out, deferring the removal until the animation is complete. For the keyboard style, simply fades out. + + Written by DJS 2009-07. +*/ + +- (void)animateRemove; +{ + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:1.0]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(removeAnimationDidStop:finished:context:)]; + + self.alpha = 0.0; + + [UIView commitAnimations]; +} + +/* + setupBackground + + Configure the background of the activity view. + + Written by DJS 2009-07. +*/ + +- (void)setupBackground; +{ + [super setupBackground]; + + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.85]; +} + +/* + makeBorderView + + Returns a new view to contain the activity indicator and label. The keyboard style has a transparent border. + + Written by DJS 2009-07. + Changed by DJS 2011-11 to simplify and make it easier to override. +*/ + +- (UIView *)makeBorderView; +{ + UIView *view = [super makeBorderView]; + + view.backgroundColor = nil; + + return view; +} + +@end + + +// ---------------------------------------------------------------------------------------- +// MARK: - +// ---------------------------------------------------------------------------------------- + + +@implementation UIApplication (KeyboardView) + +// keyboardView +// +// Copyright Matt Gallagher 2009. All rights reserved. +// +// Permission is given to use this source code file, free of charge, in any +// project, commercial or otherwise, entirely at your risk, with the condition +// that any redistribution (in part or whole) of source code must retain +// this copyright and permission notice. Attribution in compiled projects is +// appreciated but not required. + +- (UIView *)keyboardView; +{ + NSArray *windows = [self windows]; + for (UIWindow *window in [windows reverseObjectEnumerator]) + { + for (UIView *view in [window subviews]) + { + // UIPeripheralHostView is used from iOS 4.0, UIKeyboard was used in previous versions: + if (!strcmp(object_getClassName(view), "UIPeripheralHostView") || !strcmp(object_getClassName(view), "UIKeyboard")) + { + return view; + } + } + } + + return nil; +} + +@end + diff --git a/Ash_AWord/ViewControllers/My/PersonalInfoViewController.m b/Ash_AWord/ViewControllers/My/PersonalInfoViewController.m index 0523539..376f7c2 100644 --- a/Ash_AWord/ViewControllers/My/PersonalInfoViewController.m +++ b/Ash_AWord/ViewControllers/My/PersonalInfoViewController.m @@ -13,10 +13,12 @@ #import "NoteTableViewCell.h" #import "MessageTableViewCell.h" #import "MessageViewModel.h" +#import "UserViewModel.h" @interface PersonalInfoViewController () { CExpandHeader *_header; PersonalTopView* _personalTopView; + UserViewModel* _userViewModel; NSMutableArray* _imageArr; NSMutableArray* _voiceArr; BOOL _isSelectImage; @@ -42,15 +44,21 @@ _imageArr = [[NSMutableArray alloc] init]; _voiceArr = [[NSMutableArray alloc] init]; - [self loadData]; + + self.tableView.hidden = YES; + + [DejalActivityView activityViewForView:self.view withLabel:kLoadingTips]; + [self headerRereshing]; } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; _personalTopView = [Ash_UIUtil instanceXibView:@"PersonalTopView"]; - +// _personalTopView.frame = CGRectMake(0, 0, kScreenWidth, 285*[Ash_UIUtil currentScreenSizeRate]); __weak PersonalInfoViewController *weakself = self; + [_personalTopView setuserInfoViewModel:_userViewModel]; + [_personalTopView setIsSelectImg:^(BOOL isSelectImg){ _isSelectImage = isSelectImg; if (isSelectImg) { @@ -67,7 +75,9 @@ } } }]; +// [self.tableView beginUpdates]; self.tableView.tableHeaderView = _personalTopView; +// [self.tableView endUpdates]; } #pragma mark MJRefreshDelegate -(void)headerRereshing @@ -77,19 +87,38 @@ }else{ _voicePage = 1; } + [self loadUserInfo]; - [self loadData]; } -(void)footerRereshing { [self loadData]; } +-(void)loadUserInfo +{ + PropertyEntity* pro = [UserViewModel requireUserInfoWithTargetUid:_otherUserId]; + [RequireEngine requireWithProperty:pro completionBlock:^(id viewModel) { + [DejalActivityView removeView]; + self.tableView.hidden = NO; + UserViewModel* userViewModel = (UserViewModel*)viewModel; + if ([userViewModel success]) { + _userViewModel = viewModel; + [_personalTopView setuserInfoViewModel:_userViewModel]; + [self loadData]; + }else{ + [MBProgressHUD errorHudWithView:self.view label:userViewModel.errMessage hidesAfter:1.0]; + } + } failedBlock:^(NSError *error) { + self.tableView.hidden = NO; + [DejalActivityView removeView]; + }]; +} -(void)loadData { if (_isSelectImage) { PropertyEntity* pro; - if (!_otherUserId) { + if (_otherUserId && [_otherUserId isEqualToString:[AWordUser sharedInstance].uid]) { pro = [NoteViewModel requireMyWithOrder_by:Order_by_Time withPage:_imagePage withPage_size:DefaultPageSize]; }else{ pro = [NoteViewModel requireOhterWithOrder_by:Order_by_Time withPage:_imagePage withPage_size:DefaultPageSize withOtherId:_otherUserId]; @@ -122,7 +151,7 @@ }else{ PropertyEntity* pro ; - if (_otherUserId) { + if (_otherUserId && [_otherUserId isEqualToString:[AWordUser sharedInstance].uid]) { pro = [MessageViewModel requireOhterWithOrder_by:Order_by_Time withPage:_voicePage withPage_size:DefaultPageSize withOtherId:_otherUserId]; }else{ diff --git a/Ash_AWord/ViewControllers/Note/NoteCommentViewController.m b/Ash_AWord/ViewControllers/Note/NoteCommentViewController.m index 78b50c4..1e50b70 100644 --- a/Ash_AWord/ViewControllers/Note/NoteCommentViewController.m +++ b/Ash_AWord/ViewControllers/Note/NoteCommentViewController.m @@ -219,6 +219,9 @@ CommentInfoViewModel* commentInfoViewModel = [_commentInfoArr objectAtIndex:indexPath.row]; cell.ownerId = _text_image.ownerId; + [cell setCommentWithUid:^(NSString* ownerId){ + [_commentTextView showWithUid:ownerId]; + }]; [cell setCommentInfoViewModel:commentInfoViewModel]; return cell; diff --git a/Ash_AWord/ViewModels/Common/UserViewModel.h b/Ash_AWord/ViewModels/Common/UserViewModel.h index 674bce4..841a384 100644 --- a/Ash_AWord/ViewModels/Common/UserViewModel.h +++ b/Ash_AWord/ViewModels/Common/UserViewModel.h @@ -13,13 +13,21 @@ @property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSString *gender; @property (nonatomic, strong) NSString *figureurl; - +@property (nonatomic, assign) NSInteger userType; +@property (nonatomic, strong) NSString *username; +@property (nonatomic, assign) NSInteger status; +@property (nonatomic, strong) NSString *signature; +@property (nonatomic, assign) NSInteger followCount; +@property (nonatomic, assign) NSInteger followerCount; @end @interface UserViewModel : BaseViewModel @property (nonatomic, strong) NSArray *userInfoArr;; - +@property (nonatomic, strong)UserInfoViewModel* userInfo; +@property (nonatomic, assign)NSInteger relation;//与当前用户关系。0:没有关系,1:已关注此人,2:已被此人关注,3:相互关注(如果是获取自己的个人信息,可以无视该项0.0) +(PropertyEntity*)requireLoadPraiseUserWithRecordId:(NSInteger)recordId withPage:(NSInteger)page withPage_size:(NSInteger)page_size; + ++(PropertyEntity*)requireUserInfoWithTargetUid:(NSString*)targetUid; @end diff --git a/Ash_AWord/ViewModels/Common/UserViewModel.m b/Ash_AWord/ViewModels/Common/UserViewModel.m index 93f8f86..ba581b6 100644 --- a/Ash_AWord/ViewModels/Common/UserViewModel.m +++ b/Ash_AWord/ViewModels/Common/UserViewModel.m @@ -19,6 +19,7 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey { NSMutableDictionary* dic = [NSMutableDictionary dictionaryWithDictionary:[super JSONKeyPathsByPropertyKey]]; [dic setObject:@"users" forKey:@"userInfoArr"]; + [dic setObject:@"userinfo" forKey:@"userInfo"]; return dic; } - (instancetype)initWithDictionary:(NSDictionary *)dictionaryValue error:(NSError **)error { @@ -30,6 +31,9 @@ + (NSValueTransformer *)userInfoArrJSONTransformer{ return [NSValueTransformer mtl_JSONArrayTransformerWithModelClass:UserInfoViewModel.class]; } ++ (NSValueTransformer *)userInfoJSONTransformer{ + return [NSValueTransformer mtl_JSONDictionaryTransformerWithModelClass:UserInfoViewModel.class]; +} +(PropertyEntity*)requireLoadPraiseUserWithRecordId:(NSInteger)recordId withPage:(NSInteger)page withPage_size:(NSInteger)page_size { PropertyEntity *pro = [[PropertyEntity alloc] init]; @@ -46,5 +50,18 @@ }; return pro; } - ++(PropertyEntity*)requireUserInfoWithTargetUid:(NSString *)targetUid +{ + PropertyEntity *pro = [[PropertyEntity alloc] init]; + pro.requireType = HTTPRequestTypeWithPOSTDATA; + pro.responesOBJ = self.class; + + + NSDictionary* dic = @{@"targetUid": targetUid, + }; + pro.pro = @{@"root": dic, + @"command": @"10009", + }; + return pro; +} @end \ No newline at end of file diff --git a/Ash_AWord/ViewModels/Note/NoteViewModel.h b/Ash_AWord/ViewModels/Note/NoteViewModel.h index 4292dae..4402502 100644 --- a/Ash_AWord/ViewModels/Note/NoteViewModel.h +++ b/Ash_AWord/ViewModels/Note/NoteViewModel.h @@ -23,6 +23,7 @@ @property (nonatomic, assign)NSInteger shareCount; @property (nonatomic, assign)NSInteger praiseCount; @property (nonatomic, assign)NSInteger messageId; +@property (nonatomic, assign)NSInteger commentCount; @end @interface NoteViewModel : BaseViewModel diff --git a/Ash_AWord/ViewModels/Note/NoteViewModel.m b/Ash_AWord/ViewModels/Note/NoteViewModel.m index 5fdb157..335c632 100644 --- a/Ash_AWord/ViewModels/Note/NoteViewModel.m +++ b/Ash_AWord/ViewModels/Note/NoteViewModel.m @@ -23,6 +23,7 @@ @"ownerName" : @"ownerName", @"shareCount": @"shareCount", @"hasShared": @"hasShared", + @"commentCount": @"commentCount" }; } + (NSValueTransformer *)imageUrlJSONTransformer { diff --git a/Ash_AWord/Views/Common/CommentTableViewCell.h b/Ash_AWord/Views/Common/CommentTableViewCell.h index 36b41e6..0589668 100644 --- a/Ash_AWord/Views/Common/CommentTableViewCell.h +++ b/Ash_AWord/Views/Common/CommentTableViewCell.h @@ -9,6 +9,9 @@ #import #import @class CommentInfoViewModel; + +typedef void (^CommentWithUid)(NSString*); + @interface CommentTableViewCell : UITableViewCell @property (weak, nonatomic) IBOutlet UIImageView *avatarImageView; @property (weak, nonatomic) IBOutlet UILabel *nameLabel; @@ -16,7 +19,8 @@ @property (weak, nonatomic) IBOutlet UILabel *floorLabel; @property (weak, nonatomic) IBOutlet DTAttributedTextView *contentTextView; @property (strong, nonatomic)NSString* ownerId; - +@property (strong, nonatomic)CommentWithUid commentWithUid; +- (IBAction)avatarBtnClick:(id)sender; -(void)setCommentInfoViewModel:(CommentInfoViewModel*)commentInfoViewModel; +(CGFloat)getHeightWithCommentInfoViewModel:(CommentInfoViewModel*)commentInfoViewModel isReplyOwner:(BOOL)isReplyOwner; @end diff --git a/Ash_AWord/Views/Common/CommentTableViewCell.m b/Ash_AWord/Views/Common/CommentTableViewCell.m index fa12a2d..0edd77b 100644 --- a/Ash_AWord/Views/Common/CommentTableViewCell.m +++ b/Ash_AWord/Views/Common/CommentTableViewCell.m @@ -8,6 +8,10 @@ #import "CommentTableViewCell.h" #import "CommentViewModel.h" +#import "PersonalInfoViewController.h" +#import "AppDelegate.h" +@interface CommentInfoViewModel() +@end @implementation CommentTableViewCell { CommentInfoViewModel* _commentInfoViewModel; @@ -19,6 +23,11 @@ _floorLabel.layer.masksToBounds = YES; _floorLabel.layer.cornerRadius = 8.0; + + _contentTextView.textDelegate = self; + + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; + [_contentTextView addGestureRecognizer:tap]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { @@ -35,8 +44,16 @@ _floorLabel.hidden = YES; } } +- (IBAction)avatarBtnClick:(id)sender { + PersonalInfoViewController* personalInfoViewController = [[PersonalInfoViewController alloc] init]; + personalInfoViewController.hidesBottomBarWhenPushed = YES; + personalInfoViewController.otherUserId = _commentInfoViewModel.ownerId; + [[AppDelegate visibleViewController].navigationController pushViewController:personalInfoViewController animated:YES]; +} + -(void)setCommentInfoViewModel:(CommentInfoViewModel *)commentInfoViewModel { + _commentInfoViewModel = commentInfoViewModel; [_avatarImageView sd_setImageWithURL:[NSURL URLWithString:commentInfoViewModel.ownerFigureurl] placeholderImage:DefaultUserIcon]; _nameLabel.text = commentInfoViewModel.ownerName; @@ -59,7 +76,7 @@ if (!isReplyOwner){ content = [CommentTableViewCell getContentWithCommentInfoViewModel:commentInfoViewModel]; } - CGFloat height = [Ash_UIUtil calculateSizeWithHtmlstring:content limitWidth:kScreenWidth-50 withFontSize:13].height; + CGFloat height = [Ash_UIUtil calculateSizeWithHtmlstring:content limitWidth:kScreenWidth-55 withFontSize:13].height; return height+50; } @@ -76,4 +93,39 @@ return content; } + +#pragma mark DTAttributedTextContentViewDelegate +- (void)linkPushed:(DTLinkButton *)button +{ + DLog(@"%@",button.URL); + if(button.URL) + { + PersonalInfoViewController* personalInfoViewController = [[PersonalInfoViewController alloc] init]; + personalInfoViewController.hidesBottomBarWhenPushed = YES; + personalInfoViewController.otherUserId = button.URL.absoluteString; + [[AppDelegate visibleViewController].navigationController pushViewController:personalInfoViewController animated:YES]; + } +} +- (UIView *)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView viewForLink:(NSURL *)url identifier:(NSString *)identifier frame:(CGRect)frame +{ + DTLinkButton *button = [[DTLinkButton alloc] initWithFrame:frame]; + button.minimumHitSize = CGSizeMake(25, 25); // adjusts it's bounds so that button is always large enough + button.GUID = identifier; + button.URL = url; + // use normal push action for opening URL + [button addTarget:self action:@selector(linkPushed:) forControlEvents:UIControlEventTouchUpInside]; + + return button; +} + +- (void)handleTap:(UITapGestureRecognizer *)gesture +{ + if (gesture.state == UIGestureRecognizerStateRecognized) + { + if (_commentWithUid) { + _commentWithUid(_commentInfoViewModel.ownerId); + } + } +} + @end diff --git a/Ash_AWord/Views/Common/CommentTableViewCell.xib b/Ash_AWord/Views/Common/CommentTableViewCell.xib index ae1b40a..03f5ca0 100644 --- a/Ash_AWord/Views/Common/CommentTableViewCell.xib +++ b/Ash_AWord/Views/Common/CommentTableViewCell.xib @@ -40,17 +40,30 @@ - - + + + + + - + + + @@ -67,11 +80,11 @@ - - + + diff --git a/Ash_AWord/Views/Note/NoteTableViewCell.m b/Ash_AWord/Views/Note/NoteTableViewCell.m index 9051f39..f66833d 100644 --- a/Ash_AWord/Views/Note/NoteTableViewCell.m +++ b/Ash_AWord/Views/Note/NoteTableViewCell.m @@ -165,7 +165,7 @@ [_goodBtn setTitle:[NSString stringWithFormat:@"%ld",(long)text_image.praiseCount] forState:UIControlStateNormal]; [_goodBtn setTitle:[NSString stringWithFormat:@"%ld",(long)text_image.praiseCount] forState:UIControlStateSelected]; [_shareBtn setTitle:[NSString stringWithFormat:@"%ld",(long)text_image.shareCount] forState:UIControlStateNormal]; - + [_badBtn setTitle:[NSString stringWithFormat:@"%ld",(long)text_image.commentCount] forState:UIControlStateNormal]; _closeBtn.hidden = YES; [self setGoodBtnSelect:text_image.hasPraised]; diff --git a/Ash_AWord/Views/User/PersonalTopView.h b/Ash_AWord/Views/User/PersonalTopView.h index f2bbcf5..5460b71 100644 --- a/Ash_AWord/Views/User/PersonalTopView.h +++ b/Ash_AWord/Views/User/PersonalTopView.h @@ -9,6 +9,7 @@ #import typedef void (^IsSelectImage)(BOOL); +@class UserViewModel; @interface PersonalTopView : UIView @property (strong, nonatomic)IsSelectImage isSelectImg; @property (weak, nonatomic) IBOutlet UILabel *nameLabel; @@ -31,4 +32,5 @@ typedef void (^IsSelectImage)(BOOL); @property (weak, nonatomic) IBOutlet UIButton *attentionBtn; - (IBAction)attentionBtnClick:(id)sender; +-(void)setuserInfoViewModel:(UserViewModel*)userViewModel; @end diff --git a/Ash_AWord/Views/User/PersonalTopView.m b/Ash_AWord/Views/User/PersonalTopView.m index 934e2a1..c8c4923 100644 --- a/Ash_AWord/Views/User/PersonalTopView.m +++ b/Ash_AWord/Views/User/PersonalTopView.m @@ -7,7 +7,7 @@ // #import "PersonalTopView.h" - +#import "UserViewModel.h" @implementation PersonalTopView { BOOL _isSelectImage; @@ -41,6 +41,21 @@ _attentionBtn.layer.cornerRadius = 2.0; } + +-(void)setuserInfoViewModel:(UserViewModel *)userViewModel +{ + _nameLabel.text = userViewModel.userInfo.name; + _attentionCountLabel.text = [NSString stringWithFormat:@"%ld",userViewModel.userInfo.followCount]; + _fansCountLabel.text = [NSString stringWithFormat:@"%ld",userViewModel.userInfo.followerCount]; + if (userViewModel.userInfo.signature) { + _signatureLabel.text = userViewModel.userInfo.signature; + }else{ + _signatureLabel.text = @"该用户暂时没有填写签名~"; + } + + + [_avatarBtn sd_setImageWithURL:[NSURL URLWithString:userViewModel.userInfo.figureurl] forState:UIControlStateNormal placeholderImage:DefaultUserIcon]; +} - (IBAction)avatarBtnClick:(id)sender { } - (IBAction)voiceBtnClick:(id)sender { @@ -79,4 +94,5 @@ } - (IBAction)attentionBtnClick:(id)sender { } + @end diff --git a/Ash_AWord/Views/User/PersonalTopView.xib b/Ash_AWord/Views/User/PersonalTopView.xib index d5c0aa1..3b18c27 100644 --- a/Ash_AWord/Views/User/PersonalTopView.xib +++ b/Ash_AWord/Views/User/PersonalTopView.xib @@ -15,17 +15,17 @@ - + - + - + @@ -33,7 +33,7 @@ - + @@ -81,20 +81,20 @@ -