| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- //
- // JDViewController.m
- // kneet2
- //
- // Created by Created by Jason Lee on 10/1/15.
- // Copyright (c) 2015 ntels. All rights reserved.
- //
- #import "CustomTableView.h"
- #import "OptionPopOverViewController.h"
- #import "WYPopoverController.h"
- #import "JDViewController.h"
- #import "HomeMemberViewController.h"
- #import "MorePopOverViewController.h"
- @interface JDViewController () <WYPopoverControllerDelegate, UITableViewDataSource, UITableViewDelegate, MoreButtonDelegate, SocketServiceDelegate> {
- WYPopoverController *_poc;
- OptionPopOverViewController *_ovc;
- MorePopOverViewController *_MoreVc;
- }
- @end
- #pragma mark - Class Definition
- @implementation JDViewController
- @synthesize mainView = _mainView;
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self initUIOnSuper];
- [self prepareViewDidLoadOnSuper];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self addSocketDataReceive];
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self removeSocketDataReceive];
- }
- - (void)initUIOnSuper {
-
- }
- - (void)initTableViewAsDefaultStyle:(CustomTableView *)tableView {
-
- tableView.dataSource = self;
- tableView.delegate = self;
-
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.backgroundColor = [UIColor clearColor];
-
- // tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 30.0f)]; //this call table events;
- }
- - (void)prepareViewDidLoadOnSuper {
-
- }
- - (UIButton *)generateOptionButton {
-
- UIImage *image = [UIImage imageNamed:@"common_head_btn_more"];
- UIImage *imagePress = [UIImage imageNamed:@"common_head_btn_more_press"];
- CGRect btnFrame = CGRectMake(0, 0, image.size.width, image.size.height);
-
- UIButton *button = [[UIButton alloc] initWithFrame:btnFrame];
- button.tag = 9003;
-
- [button setImage:image forState:UIControlStateNormal];
- [button setImage:imagePress forState:UIControlStateHighlighted];
- [button addTarget:self action:@selector(toggleOptions:) forControlEvents:UIControlEventTouchUpInside];
-
- UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.rightBarButtonItem = item;
- return button;
- }
- - (void)toggleOptionsWithArray:(id)sender btnArray:(NSArray *)btnArray
- {
- UIButton *moreBtn = (UIButton *)sender;
-
- if (!_poc){
- _MoreVc = (MorePopOverViewController *)[CommonUtil
- instantiateViewControllerWithIdentifier:@"MorePopOverViewController"
- storyboardName:@"Common"];
- _MoreVc.delegate = self;
- _poc = [[WYPopoverController alloc] initWithContentViewController:_MoreVc];
-
- _poc.delegate = self;
- [_poc beginThemeUpdates];
-
- _poc.popoverLayoutMargins = UIEdgeInsetsMake(0, 0, 0, 0);
- _poc.theme.arrowHeight = 0;
- _poc.theme.borderWidth = 0;
- _poc.theme.innerCornerRadius = 0.0f;
- _poc.theme.outerCornerRadius = 0.0f;
- _poc.theme.minOuterCornerRadius = 0.0f;
-
- [_poc endThemeUpdates];
-
- [_MoreVc popButtonSet:btnArray];
-
-
- _MoreVc.poc = _poc;
- }
- CGRect popRect = moreBtn.bounds;
-
- [_poc presentPopoverFromRect:popRect
- inView:moreBtn
- permittedArrowDirections:WYPopoverArrowDirectionDown | WYPopoverArrowDirectionUp
- animated:YES
- options:WYPopoverAnimationOptionFadeWithScale];
-
- }
- - (void)toggleOptions:(id)sender {
- UIButton *btn = (UIButton *)sender;
- if (!_poc) {
-
- _ovc = (OptionPopOverViewController *)[CommonUtil
- instantiateViewControllerWithIdentifier:@"OptionPopOverViewController"
- storyboardName:@"Common"];
-
- _ovc.dataArray = _popooverOptionArray;
-
-
-
- _poc = [[WYPopoverController alloc] initWithContentViewController:_ovc];
- _poc.delegate = self;
- [_poc beginThemeUpdates];
- _poc.popoverLayoutMargins = UIEdgeInsetsMake(10, 0, 0, 0);
- _poc.theme.arrowHeight = 0;
- _poc.theme.borderWidth = 0;
-
- _poc.theme.usesRoundedArrow = NO;
-
- _poc.theme.arrowBase = 15;
- _poc.theme.arrowHeight = 8;
- _poc.theme.borderWidth = 0;
- // _poc.theme.tintColor = [UIColor darkGrayColor];
- _poc.theme.outerStrokeColor = kUILineColor2;
- _poc.theme.innerStrokeColor = kUILineColor2;
-
- _poc.theme.innerCornerRadius = 0.0f;
- _poc.theme.outerCornerRadius = 0.0f;
- _poc.theme.minOuterCornerRadius = 0.0f;
-
- [_poc endThemeUpdates];
-
- // [_MoreVc popButtonSet:none secondType:none thirdType:del fourthType:reload];
-
- _ovc.poc = _poc;
- }
-
- // UIBarButtonItem *barButtonItem = self.navigationItem.rightBarButtonItem;
- // UIView *itemView = [barButtonItem valueForKey:@"view"];
-
- CGRect popRect = btn.bounds;
- // popRect.origin.y = 0.0f;
-
- // [_poc presentPopoverFromRect:popRect inView:btn
- // permittedArrowDirections:WYPopoverArrowDirectionDown | WYPopoverArrowDirectionUp animated:YES options:WYPopoverAnimationOptionFadeWithScale completion:nil];
- [_poc presentPopoverFromRect:popRect
- inView:btn
- permittedArrowDirections:WYPopoverArrowDirectionDown | WYPopoverArrowDirectionUp
- animated:YES
- options:WYPopoverAnimationOptionFadeWithScale];
- // [_poc presentPopoverFromRect:popRect inView:btn
- // permittedArrowDirections:WYPopoverArrowDirectionDown | WYPopoverArrowDirectionUp animated:YES options:WYPopoverAnimationOptionFadeWithScale completion:^{
- // [_ovc.tableView reloadData];
- // }];
-
- // [_poc presentPopoverFromRect:btn.bounds
- // inView:btn
- // permittedArrowDirections:WYPopoverArrowDirectionUp
- // animated:YES
- // options:WYPopoverAnimationOptionFadeWithScale];
- }
- - (void)resetOptions {
- _ovc = nil;
- _poc = nil;
- }
- - (void)dismissOptionPopOver:(void (^)(void))completion {
- [_poc dismissPopoverAnimated:YES completion:^{
- if (completion) {
- completion();
- }
- }];
- }
- - (void)sendDataToSocket:(SocketRequestModel *)data
- {
- // [[SocketServiceHandler sharedManager] sendDataWithDelegate:data delegate:self];
- [self sendDataToSocket:data modelClass:nil];
- }
- - (void)sendDataToSocket:(SocketRequestModel *)data modelClass:(Class)modelClass
- {
- // [[SocketServiceHandler sharedManager] sendDataWithDelegate:data modelClass:modelClass delegate:self];
- [self sendDataToSocket:data modelClass:modelClass isLoading:NO];
- }
- - (void)sendDataToSocket:(SocketRequestModel *)data modelClass:(Class)modelClass isLoading:(BOOL)isLoading
- {
- [[SocketServiceHandler sharedManager] sendDataWithDelegate:data modelClass:modelClass delegate:self isShowLoading:isLoading];
- }
- - (void)sendDataToSocketWithOutDelegate:(SocketRequestModel *)data
- {
- [[SocketServiceHandler sharedManager] sendDataWihOutDelegate:data];
- }
- - (void)closeSocket{
- [[SocketServiceHandler sharedManager] close];
- }
- - (BOOL)isSocketConnected
- {
- return [[SocketServiceHandler sharedManager] isSocketConnected];
- }
- - (SRReadyState)getSocketStatus
- {
- return [[SocketServiceHandler sharedManager] getSocketStatus];
- }
- // Socket BoradCasting
- -(void)addSocketDataReceive
- {
- [self removeSocketDataReceive];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveSocketData:) name:kSocketBoradCast object:nil];
- }
- -(void)removeSocketDataReceive
- {
- @try{
- [[NSNotificationCenter defaultCenter] removeObserver:self name:kSocketBoradCast object:nil];
- }@catch(id anException){
- NSLog(@"%@", anException);
- }
- }
- -(void)receiveSocketData:(NSNotification *)notification
- {
- NSLog(@"receiveSocketData : %@", notification.object);
- }
- #pragma mark - Main Logic
- #pragma mark - UITableView DataSource & Delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
-
- // Remove seperator inset
- if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
- [cell setSeparatorInset:UIEdgeInsetsZero];
- }
-
- // Prevent the cell from inheriting the Table View's margin settings
- if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
- [cell setPreservesSuperviewLayoutMargins:NO];
- }
-
- // Explictly set your cell's layout margins
- if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
- [cell setLayoutMargins:UIEdgeInsetsZero];
- }
- }
- - (void)showTransparencyModalView:(UIViewController *)vc
- {
- vc.providesPresentationContextTransitionStyle = YES;
- vc.definesPresentationContext = YES;
-
- [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-
- UIViewController *pvc = self.presentingViewController;
- [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
- [pvc presentViewController:vc animated:YES completion:nil];
- }];
- }
- - (void)showTransparencyModalView:(UIViewController *)vc removeSelf:(BOOL)removeSelf
- {
- vc.providesPresentationContextTransitionStyle = YES;
- vc.definesPresentationContext = YES;
-
- [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-
- if (removeSelf) {
- UIViewController *pvc = self.presentingViewController;
- [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
- [pvc presentViewController:vc animated:YES completion:nil];
- }];
- } else {
- [self presentViewController:vc animated:NO completion:nil];
- }
-
- }
- #pragma mark - UI Events
- #pragma mark - MoreButtonDelegate Delegate
- #pragma mark - MemoryWarning
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|