Kaydet (Commit) ef4c98cd authored tarafından Siqi LIU's avatar Siqi LIU

add iPad specific files & ressources

Change-Id: I1bf6b4f1476ea668ea9973d8b8dfab8779cdabbc
üst ba7be1c9
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TOUCH_POINTER_ENABLED</key>
<true/>
<key>TIMER_AUTOSTART_ENABLED</key>
<false/>
</dict>
</plist>
This diff is collapsed.
//
// AppDelegate_ipad.h
// iosremote
//
// Created by Siqi Liu on 7/28/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "AppDelegate.h"
@class BasePresentationViewController;
@class MainSplitViewController;
@interface AppDelegate_ipad : AppDelegate
@end
//
// AppDelegate_ipad.m
// iosremote
//
// Created by Siqi Liu on 7/28/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "AppDelegate_ipad.h"
#import "slideShowSwipeInList_ipad.h"
#import "MainSplitViewController.h"
#import "BasePresentationViewController.h"
@implementation AppDelegate_ipad
@end
//
// ControlVariables.h
// iosremote
//
// Created by Siqi Liu on 7/28/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#ifndef iosremote_ControlVariables_h
#define iosremote_ControlVariables_h
// Width (or length before rotation) of the table view embedded within another table view's row
#define kTableLength 768
// Width of the cells of the embedded table view (after rotation, which means it controls the rowHeight property)
#define kCellWidth 172
// Height of the cells of the embedded table view (after rotation, which would be the table's width)
#define kCellHeight 129
// Padding for the Cell containing the article image and title
#define kArticleCellVerticalInnerPadding 6
#define kArticleCellHorizontalInnerPadding 7
// Padding for the title label in an article's cell
#define kArticleTitleLabelPadding 10
// Vertical padding for the embedded table view within the row
#define kRowVerticalPadding 1
// Horizontal padding for the embedded table view within the row
#define kRowHorizontalPadding 1
// The background color of the vertical table view
#define kVerticalTableBackgroundColor [UIColor colorWithRed:0.58823529 green:0.58823529 blue:0.58823529 alpha:1.0]
// Background color for the horizontal table view (the one embedded inside the rows of our vertical table)
#define kHorizontalTableBackgroundColor [UIColor blackColor]
// The background color on the horizontal table view for when we select a particular cell
#define kHorizontalTableSelectedBackgroundColor [UIColor colorWithRed:0.0 green:0.59607843 blue:0.37254902 alpha:1.0]
#define kHorizontalTableCellHighlightedBackgroundColor [UIColor colorWithRed:0 green:0.4745098 blue:0.29019808 alpha:0.9]
#endif
//
// HorizontalSlideCell.h
// iosremote
//
// Created by Siqi Liu on 7/28/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface HorizontalSlideCell : UITableViewCell
@property (strong, nonatomic) UIImageView *thumbnail;
@property (strong, nonatomic) UILabel *numberLabel;
@end
//
// HorizontalSlideCell.m
// iosremote
//
// Created by Siqi Liu on 7/28/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "HorizontalSlideCell.h"
#import "ControlVariables.h"
@implementation HorizontalSlideCell
@synthesize thumbnail = _thumbnail;
@synthesize numberLabel = _numberLabel;
- (NSString *)reuseIdentifier
{
return @"HorizontalTableSlideCell";
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
self.thumbnail = [[UIImageView alloc] initWithFrame:CGRectMake(kArticleCellHorizontalInnerPadding, kArticleCellVerticalInnerPadding, kCellWidth - kArticleCellHorizontalInnerPadding * 2, kCellHeight - kArticleCellVerticalInnerPadding * 2)];
self.thumbnail.opaque = YES;
[self.contentView addSubview:self.thumbnail];
self.numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.thumbnail.frame.size.width * 0.8, self.thumbnail.frame.size.height * 0.8, self.thumbnail.frame.size.width * 0.2, self.thumbnail.frame.size.height * 0.2)];
self.numberLabel.opaque = YES;
self.numberLabel.backgroundColor = kHorizontalTableCellHighlightedBackgroundColor;
self.numberLabel.textColor = [UIColor whiteColor];
self.numberLabel.font = [UIFont boldSystemFontOfSize:11];
self.numberLabel.textAlignment = UITextAlignmentCenter;
self.numberLabel.numberOfLines = 1;
[self.thumbnail addSubview:self.numberLabel];
self.backgroundColor = [UIColor colorWithRed:0 green:0.40784314 blue:0.21568627 alpha:1.0];
self.selectedBackgroundView = [[UIView alloc] initWithFrame:self.thumbnail.frame];
self.selectedBackgroundView.backgroundColor = kHorizontalTableSelectedBackgroundColor;
self.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// PresentationViewController.h
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "slideShowPreviewTable_vc_ipad.h"
@interface MainSplitViewController : UISplitViewController <MainSplitViewControllerProtocol>
- (void) didReceivePresentationStarted;
@property (strong, nonatomic) UIViewController * splitController;
@end
//
// PresentationViewController.m
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "MainSplitViewController.h"
#import "server_list_vc_ipad.h"
#import "CommunicationManager.h"
#import "BasePresentationViewController.h"
#import "slideShowSwipeInList_ipad.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface MainSplitViewController ()
@property UINavigationController * masterViewController;
@property BasePresentationViewController * detailViewController;
@end
@implementation MainSplitViewController
# pragma mark - System defaults
- (BOOL) shouldAutorotate
{
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[[[[UIApplication sharedApplication] delegate] window] setRootViewController:self];
// Do any additional setup after loading the view.
self.detailViewController = [self.viewControllers objectAtIndex:1];
self.masterViewController = [self.viewControllers objectAtIndex:0];
self.delegate = self.detailViewController;
}
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) didReceivePresentationStarted
{
[self.detailViewController hideMaster:NO];
[self dismissViewControllerAnimated:YES completion:nil];
// [(UITableView *)[(slideShowSwipeInList_ipad *)[[self viewControllers] objectAtIndex:2] view] reloadData];
[(slideShowSwipeInList_ipad *)[(UINavigationController *)[[self viewControllers] objectAtIndex:0] topViewController] didReceivePresentationStarted];
[(BasePresentationViewController *)[[self viewControllers] objectAtIndex:1] setWelcomePageVisible:NO];
}
@end
//
// autoDismissKeyboardNavigationViewController.h
// iosremote
//
// Created by Siqi Liu on 7/28/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface autoDismissKeyboardNavigationViewController : UINavigationController
@end
//
// autoDismissKeyboardNavigationViewController.m
// iosremote
//
// Created by Siqi Liu on 7/28/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "autoDismissKeyboardNavigationViewController.h"
@interface autoDismissKeyboardNavigationViewController ()
@end
@implementation autoDismissKeyboardNavigationViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)disablesAutomaticKeyboardDismissal
{
return NO;
}
@end
//
// server_list_vc_ipad.h
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "serverList_vc.h"
@interface server_list_vc_ipad : server_list_vc
- (IBAction)cancelModalView:(id)sender;
@end
//
// server_list_vc_ipad.m
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "server_list_vc_ipad.h"
@interface server_list_vc_ipad ()
@end
@implementation server_list_vc_ipad
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidUnload {
[super viewDidUnload];
}
#pragma mark - Actions
- (IBAction)cancelModalView:(id)sender {
[self.presentingViewController dismissModalViewControllerAnimated:YES];
}
@end
//
// slideShowPreview_vc~ipad.h
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "slideShowPreviewTable_vc.h"
@protocol MainSplitViewControllerProtocol <NSObject>
- (void) didReceivePresentationStarted;
@end
@interface slideShowPreviewTable_vc_ipad : slideShowPreviewTable_vc
@property (strong, nonatomic) id <MainSplitViewControllerProtocol> delegate;
@end
//
// slideShowPreview_vc~ipad.m
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "slideShowPreviewTable_vc_ipad.h"
#import "slideShowPreviewTable_vc.h"
#import "CommunicationManager.h"
#import "CommandTransmitter.h"
#import "CommandInterpreter.h"
#import "SlideShow.h"
#import "MainSplitViewController.h"
@interface slideShowPreviewTable_vc_ipad ()
@end
@implementation slideShowPreviewTable_vc_ipad
#pragma mark - System defaults
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void) viewDidLoad
{
[super viewDidLoad];
if (self.navigationController)
self.delegate = (MainSplitViewController *) self.navigationController.presentingViewController;
else
self.delegate = (MainSplitViewController *) self.presentingViewController;
NSLog(@"%@", [self.delegate class]);
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.optionsArray = [NSArray arrayWithObjects:OPTION_TIMER, nil];
} else
self.optionsArray = [NSArray arrayWithObjects:OPTION_TIMER, OPTION_POINTER, nil];
self.comManager = [CommunicationManager sharedComManager];
self.comManager.delegate = self;
}
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([self.comManager.interpreter.slideShow size] > 0){
NSLog(@"3");
[self.delegate didReceivePresentationStarted];
}
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.slideShowStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
[self.delegate didReceivePresentationStarted];
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// slideShowPreview_vc~iphone.h
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "slideShowPreviewTable_vc.h"
@interface slideShowPreviewTable_vc_iphone : slideShowPreviewTable_vc
@end
//
// slideShowPreview_vc~iphone.m
// iosremote
//
// Created by Siqi Liu on 7/26/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "slideShowPreviewTable_vc_iphone.h"
#import "CommandInterpreter.h"
#import "SlideShow.h"
@implementation slideShowPreviewTable_vc_iphone
- (void) viewDidLoad
{
[super viewDidLoad];
self.optionsArray = [NSArray arrayWithObjects:OPTION_TIMER, OPTION_POINTER, nil];
self.comManager = [CommunicationManager sharedComManager];
self.comManager.delegate = self;
}
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([self.comManager.interpreter.slideShow size] > 0){
[self performSegueWithIdentifier:@"slideShowSegue" sender:self];
}
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.slideShowStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
[self performSegueWithIdentifier:@"slideShowSegue" sender:self];
}];
}
@end
//
// slideShowSwipeInList~ipad.h
// iosremote
//
// Created by Siqi Liu on 7/27/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
@interface slideShowSwipeInList_ipad : UITableViewController
- (void) didReceivePresentationStarted;
@end
\ No newline at end of file
//
// slideShowSwipeInList~ipad.m
// iosremote
//
// Created by Siqi Liu on 7/27/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "slideShowSwipeInList_ipad.h"
#import "CommunicationManager.h"
#import "CommandInterpreter.h"
#import "SlideShow.h"
#import "CommandTransmitter.h"
#import "SWRevealViewController.h"
#import "slideShowPreviewTable_vc.h"
#import <QuartzCore/CALayer.h>
@interface slideShowSwipeInList_ipad ()
@property (nonatomic, strong) CommunicationManager *comManager;
@property (nonatomic, strong) SlideShow *slideshow;
@property (nonatomic, strong) id slideChangedObserver;
@end
@implementation slideShowSwipeInList_ipad
@synthesize comManager = _comManager;
@synthesize slideshow = _slideshow;
@synthesize slideChangedObserver = _slideChangedObserver;
dispatch_queue_t backgroundQueue;
- (void) handleBack:(id)sender
{
[self.comManager.transmitter stopPresentation];
[self.tableView reloadData];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (SlideShow *)slideshow
{
return self.comManager.interpreter.slideShow;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.comManager = [CommunicationManager sharedComManager];
self.slideshow.secondaryDelegate = self;
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Stop Presentation"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(handleBack:)];
[backButton setTintColor:[UIColor redColor]];
self.navigationItem.leftBarButtonItem = backButton;
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.slideChangedObserver =[center addObserverForName:MSG_SLIDE_CHANGED
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
if ([self.tableView numberOfRowsInSection:0] > 0){
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.slideshow.currentSlide inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}
}];
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"slideshowRail"]];
[bgImageView setFrame:self.tableView.frame];
self.tableView.backgroundView = bgImageView;
}
- (void)viewDidUnload
{
[[NSNotificationCenter defaultCenter] removeObserver:self.slideChangedObserver];
[super viewDidUnload];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) viewWillAppear:(BOOL)animated
{
[self.tableView reloadData];
[super viewWillAppear:animated];
}
- (void) viewDidAppear:(BOOL)animated
{
if ([self.comManager.interpreter.slideShow size] > 0) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.slideshow.currentSlide
inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
}
}
- (void) didReceivePresentationStarted
{
self.slideshow.secondaryDelegate = self;
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.slideshow size];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"Slides";
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"slide";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
UILabel * slideNumber = (UILabel *)[cell viewWithTag:2];
// Starting 20, all tags are used for thumbnails in this sidebar
[cell setTag:20+indexPath.row];
[self.slideshow getContentAtIndex:indexPath.row forView:cell];
[slideNumber setText:[NSString stringWithFormat:@"%u", indexPath.row+1]];
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
// Otherwise selection will disable background color and make slide number unreadable
if(cell.selected){
UILabel *label = (UILabel *)[cell viewWithTag:2];
if ([label backgroundColor]!=[UIColor lightGrayColor]) {
[label setBackgroundColor:[UIColor lightGrayColor]];
}
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.comManager.transmitter gotoSlide:indexPath.row];
[[[self.tableView cellForRowAtIndexPath:indexPath] viewWithTag:2] setBackgroundColor:[UIColor lightGrayColor]];
}
@end
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#import <UIKit/UIKit.h>
@interface slideShowSwipeInList : UITableViewController <UITableViewDataSource, UITableViewDelegate>
@end
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#import "slideShowSwipeInList_iphone.h"
#import "CommunicationManager.h"
#import "CommandInterpreter.h"
#import "SlideShow.h"
#import "CommandTransmitter.h"
#import "SWRevealViewController.h"
#import "slideShowPreviewTable_vc.h"
#import "ControlVariables.h"
#import "stopWatch.h"
#import <QuartzCore/CALayer.h>
@interface slideShowSwipeInList ()
@property (nonatomic, strong) CommunicationManager *comManager;
@property (nonatomic, strong) SlideShow *slideshow;
@property (nonatomic, strong) stopWatch *stopWatch;
@end
@implementation slideShowSwipeInList
@synthesize comManager = _comManager;
@synthesize slideshow = _slideshow;
dispatch_queue_t backgroundQueue;
- (void) viewDidLoad
{
[super viewDidLoad];
self.comManager = [CommunicationManager sharedComManager];
self.slideshow = self.comManager.interpreter.slideShow;
self.slideshow.secondaryDelegate = self;
self.clearsSelectionOnViewWillAppear = NO;
self.stopWatch = [[stopWatch alloc] init];
if ([[NSUserDefaults standardUserDefaults] boolForKey:KEY_TIMER]) {
[self.stopWatch start];
}
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"slideshowRail.png"]];
[tempImageView setFrame:self.tableView.frame];
self.tableView.backgroundView = tempImageView;
}
- (void) viewDidAppear:(BOOL)animated
{
if (!self.stopWatch.set) {
[self.stopWatch setupWithTableViewCell:[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]];
}
[self.stopWatch updateStartButtonIcon];
if ([self.comManager.interpreter.slideShow size] > 0) {
[self.stopWatch updateStartButtonIcon];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.slideshow.currentSlide
inSection:1];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
}
}
- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{
// configure the segue.
// in this case we dont swap out the front view controller, which is a UINavigationController.
// but we could..
if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] )
{
SWRevealViewControllerSegue* rvcs = (SWRevealViewControllerSegue*) segue;
SWRevealViewController* rvc = self.revealViewController;
NSAssert( rvc != nil, @"oops! must have a revealViewController" );
NSAssert( [rvc.frontViewController isKindOfClass: [UINavigationController class]], @"oops! for this segue we want a permanent navigation controller in the front!" );
rvcs.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc) {
UINavigationController* nc = (UINavigationController*)rvc.frontViewController;
[nc setViewControllers: @[ dvc ] animated: YES ];
[rvc setFrontViewPosition: FrontViewPositionLeft animated: YES];
};
}
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Section one used for stopwatch
if (section == 0)
return 1;
else
return [self.slideshow size];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
switch (section) {
case 0:
return @"Stop Watch";
break;
case 1:
return @"Slides";
default:
break;
}
return nil;
}
- (void) tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier: @"sw_customized_segue" sender: [tableView cellForRowAtIndexPath: indexPath]];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
static NSString *CellIdentifier = @"stopWatch";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.contentView.backgroundColor = [UIColor whiteColor];
return cell;
} else {
static NSString *CellIdentifier = @"slide";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
UILabel * slideNumber = (UILabel *)[cell viewWithTag:2];
// Starting 20, all tags are used for thumbnails in this sidebar
[cell setTag:20+indexPath.row];
[self.slideshow getContentAtIndex:indexPath.row forView:cell];
[slideNumber setText:[NSString stringWithFormat:@"%u", indexPath.row+1]];
cell.backgroundColor = [UIColor colorWithRed:0 green:0.40784314 blue:0.21568627 alpha:1.0];
return cell;
}
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
// Otherwise selection will disable background color and make slide number unreadable
if(indexPath.section == 1 && cell.selected){
UILabel *label = (UILabel *)[cell viewWithTag:2];
if ([label backgroundColor]!=[UIColor lightGrayColor]) {
[label setBackgroundColor:[UIColor lightGrayColor]];
}
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
return;
[self.comManager.transmitter gotoSlide:indexPath.row];
[[[self.tableView cellForRowAtIndexPath:indexPath] viewWithTag:2] setBackgroundColor:[UIColor lightGrayColor]];
[self.revealViewController revealToggle: self];
}
- (void)viewDidUnload {
[self setStopWatch:nil];
[super viewDidUnload];
}
@end
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#import <UIKit/UIKit.h>
#import "SlideShow.h"
@interface slideShow_vc : UIViewController <AsyncLoadHorizontalTableDelegate>
- (IBAction)nextSlideAction:(id)sender;
- (IBAction)previousSlideAction:(id)sender;
- (IBAction)pointerAction:(id)sender;
- (IBAction)accPointerAction:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *notesView;
@property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes;
@property (weak, nonatomic) IBOutlet UIImageView *slideView;
@property (weak, nonatomic) IBOutlet UIImageView *secondarySlideView;
@property (weak, nonatomic) IBOutlet UILabel *slideNumber;
@property (weak, nonatomic) IBOutlet UIView *movingPointer;
@property (weak, nonatomic) IBOutlet UIImageView *touchPointerImage;
@property (weak, nonatomic) IBOutlet UIView *blockingView;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIButton *pointerBtn;
@end
This diff is collapsed.
//
// stopWatch.h
// iosremote
//
// Created by Siqi Liu on 7/29/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <Foundation/Foundation.h>
#define TIMER_STATE_RUNNING 0
#define TIMER_STATE_PAUSED 1
#define TIMER_STATE_CLEARED 2
@interface stopWatch : NSObject
// StopWatch
@property (strong, nonatomic) NSTimer *stopWatchTimer;
@property (strong, nonatomic) NSDate *startDate;
@property BOOL set;
- (stopWatch *) initWithStartButton:(UIButton *)startButton
ClearButton:(UIButton *)clearButton
TimeLabel:(UILabel *)timeLabel;
- (void) setupWithTableViewCell:(UITableViewCell *)cell;
- (void) start;
- (void) clear;
- (void) updateStartButtonIcon;
@end
//
// stopWatch.m
// iosremote
//
// Created by Siqi Liu on 7/29/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "stopWatch.h"
@interface stopWatch ()
@property NSTimeInterval lastInterval;
@property int state;
@property (weak, nonatomic) UIButton * startButton;
@property (weak, nonatomic) UIButton * clearButton;
@property (weak, nonatomic) UILabel * timeLabel;
@end
@implementation stopWatch
@synthesize startButton = _startButton;
@synthesize clearButton = _clearButton;
@synthesize timeLabel = _timeLabel;
@synthesize lastInterval = _lastInterval;
- (stopWatch *) init
{
self = [super init];
self.state = TIMER_STATE_CLEARED;
self.set = NO;
return self;
}
- (stopWatch *) initWithStartButton:(UIButton *)startButton
ClearButton:(UIButton *)clearButton
TimeLabel:(UILabel *)timeLabel
{
self = [self init];
self.startButton = startButton;
self.clearButton = clearButton;
self.timeLabel = timeLabel;
[self setupActions];
return self;
}
- (void) setupWithTableViewCell:(UITableViewCell *)cell
{
self.startButton = (UIButton *)[cell viewWithTag:2];
self.clearButton = (UIButton *)[cell viewWithTag:3];
self.timeLabel = (UILabel *)[cell viewWithTag:1];
[self setupActions];
}
- (void) setupActions
{
[self.startButton addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside];
[self.clearButton addTarget:self action:@selector(clear) forControlEvents:UIControlEventTouchUpInside];
self.set = YES;
}
- (void)updateTimer
{
// Create date from the elapsed time
NSDate *currentDate = [NSDate date];
NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:self.startDate] + self.lastInterval;
NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
// Create a date formatter
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm:ss"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
// Format the elapsed time and set it to the label
NSString *timeString = [dateFormatter stringFromDate:timerDate];
self.timeLabel.text = timeString;
}
- (void) start
{
switch (self.state) {
case TIMER_STATE_RUNNING:
self.state = TIMER_STATE_PAUSED;
[self.stopWatchTimer invalidate];
self.lastInterval += [[NSDate date] timeIntervalSinceDate:self.startDate];
break;
case TIMER_STATE_PAUSED:
self.state = TIMER_STATE_RUNNING;
self.startDate = [NSDate date];
self.stopWatchTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/10.0
target:self
selector:@selector(updateTimer)
userInfo:nil
repeats:YES];
break;
case TIMER_STATE_CLEARED:
self.state = TIMER_STATE_RUNNING;
self.startDate = [NSDate date];
// Create the stop watch timer that fires every 100 ms
self.stopWatchTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/10.0
target:self
selector:@selector(updateTimer)
userInfo:nil
repeats:YES];
break;
default:
break;
}
[self updateStartButtonIcon];
}
- (void) updateStartButtonIcon
{
switch (self.state) {
case TIMER_STATE_RUNNING:
[self.startButton setImage:[UIImage imageNamed:@"timer_pause_btn"] forState:UIControlStateNormal];
break;
case TIMER_STATE_PAUSED:
[self.startButton setImage:[UIImage imageNamed:@"timer_resume_btn"] forState:UIControlStateNormal];
break;
case TIMER_STATE_CLEARED:
[self.startButton setImage:[UIImage imageNamed:@"timer_start_btn"] forState:UIControlStateNormal];
break;
default:
break;
}
}
- (void) clear
{
[self.stopWatchTimer invalidate];
self.stopWatchTimer = nil;
self.startDate = [NSDate date];
self.lastInterval = 0;
self.state = TIMER_STATE_CLEARED;
[self.startButton setImage:[UIImage imageNamed:@"timer_start_btn"] forState:UIControlStateNormal];
[self updateTimer];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment