From 5c6bdc3841c1d4ce22d7f8f3da83b798c587aa0e Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Thu, 5 Oct 2017 10:37:24 +0300 Subject: [ugc] [ios] Removed legacy UGC UI. --- .../Content/UGC/MWMUGCCommentCell.h | 12 -- .../Content/UGC/MWMUGCCommentCell.mm | 97 --------- .../Content/UGC/MWMUGCCommentCell.xib | 74 ------- .../Content/UGC/MWMUGCReviewController.h | 9 - .../Content/UGC/MWMUGCReviewController.mm | 78 ------- .../Content/UGC/MWMUGCReviewController.xib | 30 --- .../PlacePageLayout/Content/UGC/MWMUGCReviewVM.h | 34 ---- .../PlacePageLayout/Content/UGC/MWMUGCReviewVM.mm | 75 ------- .../Content/UGC/MWUGCCommentsController.h | 14 -- .../Content/UGC/MWUGCCommentsController.mm | 48 ----- .../Content/UGC/MWUGCCommentsController.xib | 29 --- .../Content/UGC/UGCSelectImpressionCell.xib | 226 --------------------- .../Content/UGC/UGCSpecificReviewCell.xib | 146 ------------- .../Content/UGC/UGCTextReviewCell.xib | 63 ------ 14 files changed, 935 deletions(-) delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.h delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.mm delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.xib delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.h delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.mm delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.xib delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.h delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.mm delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.h delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.mm delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.xib delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.xib delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.xib delete mode 100644 iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.xib (limited to 'iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC') diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.h deleted file mode 100644 index 80366b7045..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.h +++ /dev/null @@ -1,12 +0,0 @@ -#import "MWMTableViewCell.h" - -namespace ugc -{ -struct Review; -} - -@interface MWMUGCCommentCell : MWMTableViewCell - -- (void)configWithReview:(ugc::Review const &)review; - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.mm deleted file mode 100644 index 62d1e945fd..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.mm +++ /dev/null @@ -1,97 +0,0 @@ -#import "MWMUGCCommentCell.h" -#import "UIImageView+Coloring.h" - -#include "ugc/types.hpp" - -namespace -{ -NSString * formattedDateFrom(ugc::Time time) -{ - NSDateComponentsFormatter * formatter = [[NSDateComponentsFormatter alloc] init]; - formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleFull; - - using namespace std::chrono; - NSTimeInterval const t = duration_cast(time.time_since_epoch()).count(); - - NSDate * date = [NSDate dateWithTimeIntervalSince1970:t]; - NSCalendar * calendar = NSCalendar.currentCalendar; - auto const mask = (NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekOfMonth | - NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute); - NSDateComponents * components = [calendar components:mask fromDate:date]; - - if (components.year > 0) { - formatter.allowedUnits = NSCalendarUnitYear; - } else if (components.month > 0) { - formatter.allowedUnits = NSCalendarUnitMonth; - } else if (components.weekOfMonth > 0) { - formatter.allowedUnits = NSCalendarUnitWeekOfMonth; - } else if (components.day > 0) { - formatter.allowedUnits = NSCalendarUnitDay; - } else if (components.hour > 0) { - formatter.allowedUnits = NSCalendarUnitHour; - } else if (components.minute > 0) { - formatter.allowedUnits = NSCalendarUnitMinute; - } else { - formatter.allowedUnits = NSCalendarUnitSecond; - } - - return [formatter stringFromDateComponents:components]; -} -} - -@interface MWMUGCCommentCell () - -@property(weak, nonatomic) IBOutlet UILabel * author; -@property(weak, nonatomic) IBOutlet UILabel * date; -@property(weak, nonatomic) IBOutlet UILabel * comment; -@property(weak, nonatomic) IBOutlet UILabel * positiveCount; -@property(weak, nonatomic) IBOutlet UILabel * negativeCount; -@property(weak, nonatomic) IBOutlet UIImageView * thumbUp; -@property(weak, nonatomic) IBOutlet UIImageView * thumbDown; -@property(weak, nonatomic) IBOutlet UIButton * thumbUpButton; -@property(weak, nonatomic) IBOutlet UIButton * thumbDownButton; -@property(weak, nonatomic) IBOutlet UIButton * showOriginal; - -@end - -@implementation MWMUGCCommentCell - -- (void)configWithReview:(ugc::Review const &)review -{ - self.author.text = @(review.m_author.c_str()); - self.comment.text = @(review.m_text.m_text.c_str()); - self.date.text = formattedDateFrom(review.m_time); -} - -#pragma mark - Actions - -- (IBAction)thumbUpTap -{ - self.thumbUp.mwm_coloring = self.thumbUpButton.isSelected ? MWMImageColoringBlack : MWMImageColoringGray; - // TODO: Increment positive count - if (self.thumbDownButton.selected) - { - self.thumbDown.mwm_coloring = MWMImageColoringGray; - self.thumbDownButton.selected = NO; - // Decrement negative count - } -} - -- (IBAction)thumbDownTap -{ - self.thumbDown.mwm_coloring = self.thumbDownButton.isSelected ? MWMImageColoringBlack : MWMImageColoringGray; - // TODO: Increment negative count - if (self.thumbUpButton.selected) - { - self.thumbUp.mwm_coloring = MWMImageColoringGray; - self.thumbUpButton.selected = NO; - // Decrement positive count - } -} - -- (IBAction)showOriginalTap -{ - // TODO: Show original comment. Will be implemented soon. -} - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.xib deleted file mode 100644 index 84352a66f8..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCCommentCell.xib +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.h deleted file mode 100644 index 05e14525b9..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.h +++ /dev/null @@ -1,9 +0,0 @@ -#import "MWMTableViewController.h" - -@class MWMUGCReviewVM; - -@interface MWMUGCReviewController : MWMTableViewController - -+ (instancetype)instanceFromViewModel:(MWMUGCReviewVM *)viewModel; - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.mm deleted file mode 100644 index 8ce22d37b1..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.mm +++ /dev/null @@ -1,78 +0,0 @@ -#import "MWMUGCReviewController.h" -#import "MWMUGCReviewVM.h" -#import "SwiftBridge.h" - -#include "ugc/types.hpp" - -@interface MWMUGCReviewController () - -@property(weak, nonatomic) MWMUGCReviewVM * viewModel; - -@end - -@implementation MWMUGCReviewController - -+ (instancetype)instanceFromViewModel:(MWMUGCReviewVM *)viewModel -{ - auto inst = [[MWMUGCReviewController alloc] initWithNibName:self.className bundle:nil]; - inst.viewModel = static_cast *>(viewModel); - return inst; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - self.title = self.viewModel.name; - auto tv = self.tableView; - tv.estimatedRowHeight = 44; - tv.rowHeight = UITableViewAutomaticDimension; - [tv registerWithCellClass:[MWMUGCSpecificReviewCell class]]; - [tv registerWithCellClass:[MWMUGCTextReviewCell class]]; - self.navigationItem.rightBarButtonItem = - [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone - target:self - action:@selector(submitTap)]; -} - -- (void)submitTap -{ - [self.viewModel submit]; - [self.navigationController popViewControllerAnimated:YES]; -} - -#pragma mark - UITableView's methods - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -{ - return self.viewModel.numberOfRows; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - using ugc_review::Row; - auto vm = self.viewModel; - switch ([vm rowForIndexPath:indexPath]) - { - case Row::Detail: - { - auto const & record = [vm recordForIndexPath:indexPath]; - Class cls = [MWMUGCSpecificReviewCell class]; - auto c = static_cast([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]); - [c configWithSpecification:@(record.m_key.m_key.c_str()) - rate:static_cast(record.m_value) - atIndexPath:indexPath - delegate:vm]; - return c; - } - case Row::SpecialQuestion: - case Row::Message: - { - Class cls = [MWMUGCTextReviewCell class]; - auto c = static_cast([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]); - [c configWithDelegate:vm]; - return c; - } - } -} - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.xib deleted file mode 100644 index 1898b54ff1..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewController.xib +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.h deleted file mode 100644 index d2df3e2c5c..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.h +++ /dev/null @@ -1,34 +0,0 @@ -namespace ugc -{ -struct RatingRecord; -struct UGCUpdate; -} - -struct FeatureID; - -namespace ugc_review -{ -enum class Row -{ - Detail, - SpecialQuestion, - Message -}; -} // namespace ugc - -@interface MWMUGCReviewVM : NSObject - -+ (instancetype)fromUGC:(ugc::UGCUpdate const &)ugc - featureId:(FeatureID const &)fid - name:(NSString *)name; - -- (NSInteger)numberOfRows; -- (ugc_review::Row)rowForIndexPath:(NSIndexPath *)indexPath; -- (ugc::RatingRecord const &)recordForIndexPath:(NSIndexPath *)indexPath; -- (NSString *)review; -- (NSString *)name; - -- (void)setDefaultStarCount:(NSInteger)starCount; -- (void)submit; - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.mm deleted file mode 100644 index a8cf52fbcd..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWMUGCReviewVM.mm +++ /dev/null @@ -1,75 +0,0 @@ -#import "MWMUGCReviewVM.h" -#import "SwiftBridge.h" - -#include "Framework.h" - -#include "ugc/types.hpp" - -@interface MWMUGCReviewVM () -{ - ugc::UGCUpdate m_ugc; - FeatureID m_fid; - std::vector m_rows; -} - -@property(copy, nonatomic) NSString * review; -@property(copy, nonatomic) NSString * name; -@property(nonatomic) NSInteger starCount; - -@end - -@implementation MWMUGCReviewVM - -+ (instancetype)fromUGC:(ugc::UGCUpdate const &)ugc - featureId:(FeatureID const &)fid - name:(NSString *)name -{ - auto inst = [[MWMUGCReviewVM alloc] init]; - inst.name = name; - inst->m_ugc = ugc; - inst->m_fid = fid; - [inst config]; - return inst; -} - -- (void)config -{ - // TODO: Config controller with ugc. -} - -- (void)setDefaultStarCount:(NSInteger)starCount -{ - // TODO: Set stars count. -} - -- (void)submit -{ - GetFramework().GetUGCApi()->SetUGCUpdate(m_fid, m_ugc); -} - -- (NSInteger)numberOfRows { return m_rows.size(); } - -- (ugc::RatingRecord const &)recordForIndexPath:(NSIndexPath *)indexPath -{ - // TODO: Return rating record from ugc. - return ugc::RatingRecord(); -} - -- (ugc_review::Row)rowForIndexPath:(NSIndexPath *)indexPath { return m_rows[indexPath.row]; } - -#pragma mark - MWMUGCSpecificReviewDelegate - -- (void)changeReviewRate:(NSInteger)rate atIndexPath:(NSIndexPath *)indexPath -{ - //TODO: Change review rate. -} - -#pragma mark - MWMUGCTextReviewDelegate - -- (void)changeReviewText:(NSString *)text -{ - self.review = text; - // TODO: Write the review into ugc object. -} - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.h deleted file mode 100644 index 373deb03f9..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.h +++ /dev/null @@ -1,14 +0,0 @@ -#import "MWMTableViewController.h" - -#include - -namespace ugc -{ -struct Review; -} - -@interface MWUGCCommentsController : MWMTableViewController - -+ (instancetype)instanceWithTitle:(NSString *)title comments:(std::vector const &)comments; - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.mm deleted file mode 100644 index 50690fb431..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.mm +++ /dev/null @@ -1,48 +0,0 @@ -#import "MWUGCCommentsController.h" -#import "MWMUGCCommentCell.h" -#import "SwiftBridge.h" - -#include "ugc/types.hpp" - -@interface MWUGCCommentsController () -{ - std::vector m_dataSource; -} - -@end - -@implementation MWUGCCommentsController - -+ (instancetype)instanceWithTitle:(NSString *)title comments:(std::vector const &)comments -{ - auto inst = [[MWUGCCommentsController alloc] initWithNibName:self.className bundle:nil]; - inst.title = title; - inst->m_dataSource = comments; - return inst; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - auto tv = self.tableView; - tv.estimatedRowHeight = 44; - tv.rowHeight = UITableViewAutomaticDimension; - [tv registerWithCellClass:[MWMUGCCommentCell class]]; -} - -#pragma mark - UITableView's methods - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -{ - return m_dataSource.size(); -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - Class cls = [MWMUGCCommentCell class]; - auto c = static_cast([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]); - [c configWithReview:m_dataSource[indexPath.row]]; - return c; -} - -@end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.xib deleted file mode 100644 index 795d074b77..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/MWUGCCommentsController.xib +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.xib deleted file mode 100644 index fbed803496..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.xib +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.xib deleted file mode 100644 index 16977c3b57..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.xib +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.xib deleted file mode 100644 index a6a63c259d..0000000000 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.xib +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3