Commit 51e5d3ff authored by Alex Moore's avatar Alex Moore

started UI iteration 3, added vibrate setting

parent ab1c70aa
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:PLUCdraft.xcodeproj">
</FileRef>
</Workspace>
//
// AppDelegate.h
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
//
// AppDelegate.m
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 Alexander W. Moore. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PLUCdraft" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>
This diff is collapsed.
//
// DummyData.h
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface DummyData : NSObject
@property (readonly) NSString *username;
@property (readonly) NSString *password;
@end
//
// DummyData.m
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import "DummyData.h"
@implementation DummyData
@end
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>SD1.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// LogInViewController.h
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LogInViewController : UIViewController
@property (weak, nonatomic, readonly) UIButton *btnLogIn;
@property (weak, nonatomic, readonly) UITextField *txtUsername;
@property (weak, nonatomic, readonly) UITextField *txtPassword;
@end
//
// LogInViewController.m
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import "LogInViewController.h"
@interface LogInViewController ()
@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtUsername;
@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtPassword;
- (IBAction)btnLogInTouch:(id)sender;
@end
@implementation LogInViewController
@synthesize txtUsername;
@synthesize txtPassword;
static NSString *USERNAME = @"alex";
static NSString *PASSWORD = @"what";
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(endEditing:)]];
self.navigationItem.hidesBackButton = YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)btnLogInTouch:(id)sender {
if([txtUsername.text isEqualToString: USERNAME] && [txtPassword.text isEqualToString:PASSWORD]) {//check username and password
[self performSegueWithIdentifier:@"segueLogIn" sender:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Incorrect login" message:@"Username or password incorrect" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
@end
//
// ScanBookViewController.h
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Session.h"
@interface ScanBookViewController : UIViewController
@property Session *session;
@property (nonatomic) BOOL *vibrate;
@end
//
// ScanBookViewController.m
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import "ScanBookViewController.h"
#import <AudioToolbox/AudioToolbox.h>
static int BOOK_ID_LENGTH = 13;
@interface ScanBookViewController ()
@property (weak, nonatomic) IBOutlet UITextField *txtBookID;
@property (weak, nonatomic) IBOutlet UIImageView *imgCheck;
@property (weak, nonatomic) IBOutlet UIImageView *imgX;
@property (weak, nonatomic) IBOutlet UILabel *lblSection;
- (IBAction)txtChange:(id)sender;
@end
@implementation ScanBookViewController
@synthesize session;
@synthesize lblSection;
@synthesize txtBookID;
@synthesize imgCheck;
@synthesize imgX;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
lblSection.text = session.section;
[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(endEditing:)]];
// SEND SESSION TO RTI
//self.navigationItem.hidesBackButton = YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
// TELL OCI TO END SESSION aka exit out of page
}
-(void) changeCheckImage {
imgCheck.image = [UIImage imageNamed:@"greencheck.png"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
sleep(1);
//do other stuff
dispatch_async(dispatch_get_main_queue(), ^{
imgCheck.image = [UIImage imageNamed:@"greycheck2.png"];
txtBookID.text = @"";
});
});
}
-(void) changeXImage {
imgX.image = [UIImage imageNamed:@"redx.png"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
sleep(1);
//do other stuff
dispatch_async(dispatch_get_main_queue(), ^{
imgX.image = [UIImage imageNamed:@"greyx2.png"];
txtBookID.text = @"";
});
});
}
- (IBAction)txtChange:(id)sender {
NSCharacterSet* notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
if(txtBookID.text.length == BOOK_ID_LENGTH) { //string is proper length
if([txtBookID.text rangeOfCharacterFromSet:notDigits].location == NSNotFound) { //string is numeric
// SEND BOOK ID TO RTI
//randomly generate errors
int random = arc4random() % 10;
if(random < 5) {
//green check
[self changeCheckImage];
if(_vibrate) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
} else {
//red x
[self changeXImage];
if(_vibrate) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
}
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Book ID" message:@"Book ID must be numeric" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
} else {
//if not 13 digits
}
}
@end
//
// SectionTableViewController.h
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Session.h"
#import "ScanBookViewController.h"
@interface SectionTableViewController : UITableViewController
@end
//
// SectionTableViewController.m
// PLUCdraft
//
// Created by Alexander W. Moore on 2/3/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import "SectionTableViewController.h"
@interface SectionTableViewController ()
@property NSMutableArray *sections;
@end
@implementation SectionTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.sections = [[NSMutableArray alloc] init];
[self loadInitialData];
}
-(void)loadInitialData {
[self.sections addObject:@"Adult Non-Fiction"];
[self.sections addObject:@"Adult Fiction"];
[self.sections addObject:@"Adult Semi-Fiction"];
[self.sections addObject:@"Children Non-Fiction"];
[self.sections addObject:@"Children Fiction"];
[self.sections addObject:@"CD"];
[self.sections addObject:@"DVD"];
[self.sections addObject:@"Blu-Ray"];
[self.sections addObject:@"VHS"];
[self.sections addObject:@"Game of Thrones"];
[self.sections addObject:@"Poetry"];
[self.sections addObject:@"Encyclopedias"];
[self.sections addObject:@"Stuff"];
[self.sections addObject:@"Other"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [self.sections count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListPrototypeCell" forIndexPath:indexPath];
// Configure the cell...
NSString *section = [self.sections objectAtIndex:indexPath.row];
cell.textLabel.text = section;
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
Session *session = [[Session alloc] init];
session.section = [self.sections objectAtIndex:path.row];
ScanBookViewController *destViewController = [segue destinationViewController];
destViewController.session = session;
}
@end
//
// Session.h
// PLUCdraft
//
// Created by Alexander W. Moore on 2/5/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Session : NSObject
@property NSString* section;
@property int numScanned;
-(void) incrementNumScanned;
@end
//
// Session.m
// PLUCdraft
//
// Created by Alexander W. Moore on 2/5/15.
// Copyright (c) 2015 Alexander W. Moore. All rights reserved.
//
#import "Session.h"
@implementation Session
-(void) incrementNumScanned {
self.numScanned ++;
}
@end
//
// SettingsViewController.h
// PLUCdraft