Skip to content

Commit

Permalink
Merge pull request #198 from ZeusWPI/ios/v2.0
Browse files Browse the repository at this point in the history
iOS/v2.0
  • Loading branch information
feliciaan committed Nov 27, 2015
2 parents 6cae896 + 3c73aac commit d41d08e
Show file tree
Hide file tree
Showing 91 changed files with 3,490 additions and 3,458 deletions.
31 changes: 27 additions & 4 deletions iOS/Hydra-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -40,29 +40,52 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.2.2</string>
<string>2.0.15</string>
<key>FacebookAppID</key>
<string>146947948791011</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>ugent.be</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We hebben uw locatie nodig om deze te kunnen tonen op de kaarten.</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UILaunchStoryboardName</key>
<string>DashboardViewController</string>
<string>MainStoryboard</string>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiresFullScreen</key>
<false/>
<key>UIStatusBarHidden</key>
<false/>
<key>UIStatusBarHidden~ipad</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
Expand Down
275 changes: 223 additions & 52 deletions iOS/Hydra.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

152 changes: 14 additions & 138 deletions iOS/Hydra/ActivitiesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#import "NSDateFormatter+AppLocale.h"
#import "PreferencesService.h"
#import "RMPickerViewController.h"
#import "Hydra-Swift.h"
#import <SVProgressHUD/SVProgressHUD.h>

#define kCellTitleLabel 101
#define kCellSubtitleLabel 102

@interface ActivitiesController () <ActivityListDelegate, UIPickerViewDataSource, UIPickerViewDelegate, UISearchDisplayDelegate, RMPickerViewControllerDelegate>

@property (nonatomic, assign) BOOL activitiesUpdated;
Expand Down Expand Up @@ -87,6 +85,9 @@ - (void)viewDidLoad

[RMPickerViewController setLocalizedTitleForCancelButton:@"Sluit"];
[RMPickerViewController setLocalizedTitleForSelectButton:@"Gereed"];

UINib *nib = [UINib nibWithNibName:@"ActivityOverviewCell" bundle:nil];
[self.tableView registerNib:nib forCellReuseIdentifier:@"ActivityOverviewCell"];
}

- (void)viewWillAppear:(BOOL)animated
Expand Down Expand Up @@ -209,88 +210,20 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 46;
return 44;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UILabel *titleLabel, *subtitleLabel;

NSDate *date = self.days[indexPath.section];
AssociationActivity *activity = self.data[date][indexPath.row];
static NSString *NoHighlightCellIdentifier = @"ActivityCellNoHighlight";
static NSString *HighlightCellIdentifier = @"ActivityCellHighlight";
UITableViewCell *cell;

if (!activity.highlighted) {
// request cell without the special star view
cell = [tableView dequeueReusableCellWithIdentifier:NoHighlightCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:NoHighlightCellIdentifier];
[self setupCell:cell withRightMargin:10];
}
}
else {
// request cell with special star view
cell = [tableView dequeueReusableCellWithIdentifier:HighlightCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:HighlightCellIdentifier];
[self setupCell:cell withRightMargin:40];

UIImageView *star = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"icon-star"]];
star.frame = CGRectMake(286, 8, 27, 27);
[cell.contentView addSubview:star];
}
}
titleLabel = (UILabel *)[cell viewWithTag:kCellTitleLabel];
subtitleLabel = (UILabel *)[cell viewWithTag:kCellSubtitleLabel];

static NSDateFormatter *dateFormatter = nil;
if (!dateFormatter) {
dateFormatter = [NSDateFormatter H_dateFormatterWithAppLocale];
dateFormatter.dateFormat = @"HH.mm";
}

cell.textLabel.text = [dateFormatter stringFromDate:activity.start];
titleLabel.text = activity.title;
subtitleLabel.text = activity.association.displayName;
static NSString *CellIdentifier = @"ActivityOverviewCell";
ActivityOverviewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

cell.activity = activity;
return cell;
}

- (void)setupCell:(UITableViewCell *)cell withRightMargin:(int)rightMargin
{
cell.textLabel.font = [UIFont boldSystemFontOfSize:15.0f];
cell.textLabel.textColor = [UIColor colorWithWhite:0.5 alpha:1];
cell.textLabel.highlightedTextColor = [UIColor colorWithWhite:0.94 alpha:1];

// iOS7
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
cell.separatorInset = UIEdgeInsetsZero;
}

CGFloat offsetX = IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") ? 64 : 60;
CGFloat width = self.view.bounds.size.width - offsetX - rightMargin;

CGRect titleFrame = CGRectMake(offsetX, 4, width, 20);
UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleFrame];
titleLabel.tag = kCellTitleLabel;
titleLabel.font = [UIFont boldSystemFontOfSize:17.0f];
titleLabel.highlightedTextColor = [UIColor whiteColor];
[cell.contentView addSubview:titleLabel];

CGRect subtitleFrame = CGRectMake(offsetX, 24, width, 16);
UILabel *subtitleLabel = [[UILabel alloc] initWithFrame:subtitleFrame];
subtitleLabel.tag = kCellSubtitleLabel;
subtitleLabel.font = [UIFont systemFontOfSize:13.0f];
subtitleLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1];
subtitleLabel.highlightedTextColor = [UIColor whiteColor];
[cell.contentView addSubview:subtitleLabel];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDate *date = self.days[indexPath.section];
Expand Down Expand Up @@ -439,70 +372,13 @@ - (void)didSelectActivity:(AssociationActivity *)activity

- (void)dateButtonTapped:(id)sender
{
if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
RMPickerViewController *pickerVC = [RMPickerViewController pickerController];
pickerVC.delegate = self;
UIPickerView *picker = pickerVC.picker;
NSInteger row = ((NSIndexPath *)[self.tableView indexPathsForVisibleRows][0]).section;
[picker selectRow:row inComponent:0 animated:NO];
RMPickerViewController *pickerVC = [RMPickerViewController pickerController];
pickerVC.delegate = self;
UIPickerView *picker = pickerVC.picker;
NSInteger row = ((NSIndexPath *)[self.tableView indexPathsForVisibleRows][0]).section;
[picker selectRow:row inComponent:0 animated:NO];

[pickerVC show];
} else {
// TODO: this is abuse of UIActionSheet, and shouldn't be used like this
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];

BOOL iOS7 = IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0");

// Create toolbar
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil action:nil];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"Gereed" style:UIBarButtonItemStyleBordered
target:self action:@selector(dismissActionSheet:)];
UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.tintColor = [UIColor hydraTintColor];
pickerToolbar.items = @[flexSpace, doneBtn];

if (iOS7) {
// Add a gray border to the bottom of the toolbar
CALayer *border = [CALayer layer];
border.borderColor = [UIColor lightGrayColor].CGColor;
border.borderWidth = 0.25;
border.frame = CGRectMake(0, pickerToolbar.frame.size.height,
pickerToolbar.frame.size.width, 0.25);
[pickerToolbar.layer addSublayer:border];
}

[actionSheet addSubview:pickerToolbar];

UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 12, 290, 22)];
title.font = [UIFont boldSystemFontOfSize:18];
title.text = @"Selecteer een dag";
title.textAlignment = NSTextAlignmentCenter;
title.backgroundColor = [UIColor clearColor];

if (!iOS7) {
title.textColor = [UIColor whiteColor];
title.shadowColor = [UIColor darkTextColor];
}
[actionSheet addSubview:title];

// Create datepicker
self.datePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, iOS7 ? 34 : 44, 0, 0)];
self.datePicker.showsSelectionIndicator = YES;
self.datePicker.dataSource = self;
self.datePicker.delegate = self;
[actionSheet addSubview:self.datePicker];

NSIndexPath *firstSection = [self.tableView indexPathsForVisibleRows][0];
[self.datePicker selectRow:firstSection.section inComponent:0 animated:NO];

[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 500)];
}
[pickerVC show];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
Expand Down
29 changes: 8 additions & 21 deletions iOS/Hydra/ActivityDetailController.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
// Different calculation for UITextView
if (!self.descriptionView) {
self.descriptionView = [self createDescriptionView];
if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
width = tableView.frame.size.width;
} else {
width = tableView.frame.size.width - 20;
self.descriptionView.frame = CGRectMake(0, 0, width, 0);
}
width = tableView.frame.size.width;
}
if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
UIEdgeInsets textContainerInsets = self.descriptionView.textContainerInset;
Expand Down Expand Up @@ -502,11 +497,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView infoCellForRowAtIndex:(N
cell.textLabel.text = @"Gasten";
cell.alignToTop = YES;

if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")){
cell.accessoryType = UITableViewCellAccessoryDetailButton;
} else {
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
cell.accessoryType = UITableViewCellAccessoryDetailButton;

FacebookEvent *event = self.activity.facebookEvent;
if (event.friendsAttending.count > 0) {
Expand Down Expand Up @@ -683,16 +674,12 @@ - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexP
- (void)addEventToCalendar
{
EKEventStore *store = [[EKEventStore alloc] init];
if ([store respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (!granted) return;
[self performSelectorOnMainThread:@selector(addEventWithCalendarStore:)
withObject:store waitUntilDone:NO];
}];
}
else {
[self addEventWithCalendarStore:store];
}

[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (!granted) return;
[self performSelectorOnMainThread:@selector(addEventWithCalendarStore:)
withObject:store waitUntilDone:NO];
}];
}

- (void)addEventWithCalendarStore:(EKEventStore *)store
Expand Down
30 changes: 30 additions & 0 deletions iOS/Hydra/ActivityOverviewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// ActivityOverviewCell.swift
// Hydra
//
// Created by Feliciaan De Palmenaer on 24/11/2015.
// Copyright © 2015 Zeus WPI. All rights reserved.
//

import UIKit

@objc class ActivityOverviewCell: UITableViewCell {

@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var associationLabel: UILabel!
@IBOutlet weak var dateLabel: UILabel!

var activity: AssociationActivity? {
didSet {
associationLabel.text = activity?.association.displayName
titleLabel.text = activity?.title

let dateStartFormatter = NSDateFormatter.H_dateFormatterWithAppLocale()
dateStartFormatter.dateFormat = "H:mm";
dateLabel.text = "\(dateStartFormatter.stringFromDate((self.activity?.start)!))"

//TODO: do something if highlighted
}
}

}
Loading

0 comments on commit d41d08e

Please sign in to comment.