Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
normansander committed Apr 7, 2015
2 parents 1650491 + 6501624 commit 49cde05
Show file tree
Hide file tree
Showing 27 changed files with 330 additions and 205 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ xcuserdata
Pods/
Podfile.lock
CriticalMaps.xcodeproj

PLAdditional.h
PLAdditional.m
14 changes: 13 additions & 1 deletion CriticalMaps.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
90F46A24D8DB4FCAABF4CF34 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FD3CAC801A84BBA8D151E5D /* libPods.a */; };
940A9AEE1AC861C800F90DC3 /* PLAdditional.m in Sources */ = {isa = PBXBuildFile; fileRef = 940A9AED1AC861C800F90DC3 /* PLAdditional.m */; };
941511091A10004D0010205B /* PLTwitterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 941511081A10004D0010205B /* PLTwitterViewController.m */; };
942B71B61A5770CA00D02CA1 /* PLTwitterTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 942B71B51A5770CA00D02CA1 /* PLTwitterTableViewCell.m */; };
942E2D8219C316BD00BF92D7 /* PLUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 942E2D8119C316BD00BF92D7 /* PLUtils.m */; };
Expand All @@ -34,6 +35,7 @@
94CF089619BDECAE009FFF43 /* PLRulesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 94CF089519BDECAE009FFF43 /* PLRulesViewController.m */; };
94CF089919BDF227009FFF43 /* PLTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 94CF089819BDF227009FFF43 /* PLTabBarController.m */; };
94DC348E1A9E5C39000E9D85 /* PLChatObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 94DC348D1A9E5C39000E9D85 /* PLChatObject.m */; };
94ECBDA61AD1B7CC00A8D75A /* UIColor+Helper.m in Sources */ = {isa = PBXBuildFile; fileRef = 94ECBDA51AD1B7CC00A8D75A /* UIColor+Helper.m */; };
94F0304919C1E4EC00F86611 /* PLConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 94F0304819C1E4EC00F86611 /* PLConstants.m */; };
/* End PBXBuildFile section */

Expand All @@ -50,6 +52,8 @@
/* Begin PBXFileReference section */
1FD3CAC801A84BBA8D151E5D /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
42F8D420591A3C7DB831663C /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
940A9AEC1AC861C800F90DC3 /* PLAdditional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLAdditional.h; sourceTree = "<group>"; };
940A9AED1AC861C800F90DC3 /* PLAdditional.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLAdditional.m; sourceTree = "<group>"; };
941511071A10004D0010205B /* PLTwitterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLTwitterViewController.h; sourceTree = "<group>"; };
941511081A10004D0010205B /* PLTwitterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLTwitterViewController.m; sourceTree = "<group>"; };
942B71B41A5770CA00D02CA1 /* PLTwitterTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLTwitterTableViewCell.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -94,6 +98,8 @@
94CF089819BDF227009FFF43 /* PLTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLTabBarController.m; sourceTree = "<group>"; };
94DC348C1A9E5C39000E9D85 /* PLChatObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLChatObject.h; sourceTree = "<group>"; };
94DC348D1A9E5C39000E9D85 /* PLChatObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLChatObject.m; sourceTree = "<group>"; };
94ECBDA41AD1B7CC00A8D75A /* UIColor+Helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Helper.h"; sourceTree = "<group>"; };
94ECBDA51AD1B7CC00A8D75A /* UIColor+Helper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Helper.m"; sourceTree = "<group>"; };
94F0304719C1E4EC00F86611 /* PLConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLConstants.h; sourceTree = "<group>"; };
94F0304819C1E4EC00F86611 /* PLConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLConstants.m; sourceTree = "<group>"; };
EB65E4E1C81486F82961461F /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -140,13 +146,13 @@
94AD50481A963DC800547B40 /* Controller */ = {
isa = PBXGroup;
children = (
9474656219CA3078005485BD /* PLSettingsTableViewController.h */,
94CF089119BDEC9C009FFF43 /* PLMapViewController.h */,
94CF089219BDEC9C009FFF43 /* PLMapViewController.m */,
94CF089419BDECAE009FFF43 /* PLRulesViewController.h */,
94CF089519BDECAE009FFF43 /* PLRulesViewController.m */,
941511071A10004D0010205B /* PLTwitterViewController.h */,
941511081A10004D0010205B /* PLTwitterViewController.m */,
9474656219CA3078005485BD /* PLSettingsTableViewController.h */,
9474656319CA3078005485BD /* PLSettingsTableViewController.m */,
94591A691A6C67640080BCEC /* PLChatViewController.h */,
94591A6A1A6C67640080BCEC /* PLChatViewController.m */,
Expand Down Expand Up @@ -180,6 +186,10 @@
94F0304819C1E4EC00F86611 /* PLConstants.m */,
942E2D8019C316BD00BF92D7 /* PLUtils.h */,
942E2D8119C316BD00BF92D7 /* PLUtils.m */,
940A9AEC1AC861C800F90DC3 /* PLAdditional.h */,
940A9AED1AC861C800F90DC3 /* PLAdditional.m */,
94ECBDA41AD1B7CC00A8D75A /* UIColor+Helper.h */,
94ECBDA51AD1B7CC00A8D75A /* UIColor+Helper.m */,
);
name = Root;
sourceTree = "<group>";
Expand Down Expand Up @@ -413,7 +423,9 @@
942E2D8219C316BD00BF92D7 /* PLUtils.m in Sources */,
94AD50461A963D0600547B40 /* PLChatModel.m in Sources */,
94A9C1AF19BF43AB0027C5DC /* PLDataModel.m in Sources */,
94ECBDA61AD1B7CC00A8D75A /* UIColor+Helper.m in Sources */,
945441AE1A111A6A00C8024F /* PLLabel.m in Sources */,
940A9AEE1AC861C800F90DC3 /* PLAdditional.m in Sources */,
94F0304919C1E4EC00F86611 /* PLConstants.m in Sources */,
94CF089919BDF227009FFF43 /* PLTabBarController.m in Sources */,
9484E8031A62E63F0007F9F3 /* HOButton.m in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions CriticalMass/CriticalMaps-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.5.4</string>
<string>0.6.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.5.4.2</string>
<string>0.6.0.2</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 2 additions & 0 deletions CriticalMass/PLAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "PLRulesViewController.h"
#import "PLConstants.h"
#import "PLDataModel.h"
#import "PLAdditional.h"
#import "Appirater.h"

@implementation PLAppDelegate
Expand All @@ -31,6 +32,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[Appirater setDebug:YES];
}

[PLAdditional setup];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
Expand Down
3 changes: 1 addition & 2 deletions CriticalMass/PLChatModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

@interface PLChatModel : NSObject

@property(nonatomic, strong) PLDataModel *data;
@property(nonatomic, strong) NSMutableArray *messages;
@property(nonatomic, readonly) NSMutableArray *messages;

+ (id)sharedManager;
- (void)collectMessage:(NSString*)message;
Expand Down
12 changes: 6 additions & 6 deletions CriticalMass/PLChatModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#import "PLChatObject.h"
#import <NSString+Hashes.h>

@interface PLChatModel()

@property(nonatomic, strong) PLDataModel *data;

@end

@implementation PLChatModel

+ (id)sharedManager {
Expand Down Expand Up @@ -44,12 +50,6 @@ - (void)collectMessage:(NSString*) text {
co.isActive = NO;

[_messages addObject:co];

// TODO: sort not working here WTF
// [_messages sortUsingDescriptors:
// [NSArray arrayWithObjects:
// [NSSortDescriptor sortDescriptorWithKey:@"timestamp" ascending:YES], nil]];

[_data request];

// notify view
Expand Down
7 changes: 0 additions & 7 deletions CriticalMass/PLChatViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,4 @@

@interface PLChatViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>

@property (nonatomic, strong) PLChatModel *chatModel;
@property (nonatomic, strong) PLDataModel *dataModel;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *controlView;
@property (nonatomic, strong) UITextField *textField;
@property (nonatomic, strong) HOButton *btnSend;

@end
66 changes: 47 additions & 19 deletions CriticalMass/PLChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
#import "PLChatViewController.h"
#import "PLChatObject.h"
#import "PLConstants.h"
#import "UIColor+Helper.h"

@interface PLChatViewController ()

@property (nonatomic, strong) PLChatModel *chatModel;
@property (nonatomic, strong) PLDataModel *dataModel;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *controlView;
@property (nonatomic, strong) UITextField *textField;
@property (nonatomic, strong) HOButton *btnSend;

@end

@implementation PLChatViewController
Expand All @@ -24,21 +32,29 @@ - (void)viewDidLoad {
_dataModel = [PLDataModel sharedManager];
_chatModel = [PLChatModel sharedManager];

// navbar
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)];
navBar.backgroundColor = [UIColor whiteColor];
UINavigationItem *navItem = [[UINavigationItem alloc] init];
navItem.title = [@"Chat" uppercaseString];
navBar.items = @[ navItem ];
navBar.translucent = NO;
[self.view addSubview:navBar];

// add table
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height-140)];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 71, self.view.frame.size.width, self.view.frame.size.height-189)];
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.view addSubview: self.tableView];

// add
// add gesture recognizer
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];
[self.tableView addGestureRecognizer:gesture];

// add control
self.controlView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-110, self.view.frame.size.width, 50)];
[self.view addSubview:self.controlView];


// add textfield
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 0, 240, 50)];
self.textField.layer.borderWidth = 1.0;
Expand All @@ -57,24 +73,18 @@ - (void)viewDidLoad {
}

-(void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMessagesReceived) name:kNotificationChatMessagesReceived object:_chatModel];

}

-(void)viewWillDisappear:(BOOL)animated {

[super viewWillDisappear:animated];

[[NSNotificationCenter defaultCenter] removeObserver:self
name:kNotificationChatMessagesReceived
object:nil];
}

-(void)viewDidAppear:(BOOL)animated{

[super viewDidAppear:animated];
[self.view endEditing:YES]; // Hide keyboard

Expand Down Expand Up @@ -121,28 +131,47 @@ - (void)moveContent:(BOOL)moveUp{

#pragma mark - UITableViewDataSource Methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

if (_chatModel.messages.count) {
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self.tableView.backgroundView = nil;
return 1;
} else {

// Display a message when the table is empty
UILabel *messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];

messageLabel.text = @"No chat activity at the moment...";
messageLabel.textColor = [UIColor blackColor];
messageLabel.numberOfLines = 0;
messageLabel.textAlignment = NSTextAlignmentCenter;
// messageLabel.font = [UIFont fontWithName:@"Palatino-Italic" size:20];
[messageLabel sizeToFit];

self.tableView.backgroundView = messageLabel;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _chatModel.messages.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];

if(!_chatModel.messages){
return cell;
}

if(!(_chatModel.messages.count > indexPath.row)){
return cell;
}

PLChatObject *message = [_chatModel.messages objectAtIndex:indexPath.row];

cell.textLabel.text = message.text;
cell.imageView.image = [UIImage imageNamed:@"Punk"];
cell.imageView.image = [cell.imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
cell.imageView.tintColor = [UIColor magicColor];
cell.imageView.frame = CGRectMake(0,0,12,12);

if(message.isActive){
Expand Down Expand Up @@ -191,5 +220,4 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
[self.textField resignFirstResponder];
}


@end
1 change: 0 additions & 1 deletion CriticalMass/PLConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ FOUNDATION_EXPORT NSTimeInterval const kRequestRepeatTime;
FOUNDATION_EXPORT NSUInteger const kMaxRequestsInBackground;
FOUNDATION_EXPORT double const kTestLocationLatitude;
FOUNDATION_EXPORT double const kTestLocationLongitude;
FOUNDATION_EXPORT NSString *const kTwitterQuery;

@end
2 changes: 0 additions & 2 deletions CriticalMass/PLConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ @implementation PLConstants
BOOL const kDebugInitialTabIndex = 0;
BOOL const kDebugShowAppirater = NO;


// Urls
NSString *const kUrlService = @"http://api.criticalmaps.net/postv2";

Expand All @@ -35,4 +34,3 @@ @implementation PLConstants
NSUInteger const kMaxRequestsInBackground = 480;
double const kTestLocationLatitude = +52.50266880;
double const kTestLocationLongitude = +13.41227278;
NSString *const kTwitterQuery = @"#criticalmaps";
10 changes: 2 additions & 8 deletions CriticalMass/PLDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@

@class PLChatModel;

@interface PLDataModel : NSObject<CLLocationManagerDelegate>{

CLLocationManager *_locationManager;
AFHTTPRequestOperationManager *_operationManager;
NSTimer *_timer;
NSUInteger _updateCount;
NSUInteger _requestCount;
}
@interface PLDataModel : NSObject<CLLocationManagerDelegate>

@property (nonatomic, readonly) NSString *uid;
@property (nonatomic, readonly) NSString *locality;
@property (nonatomic, readonly) CLLocation *currentLocation;
@property (nonatomic, readonly) NSDictionary *otherLocations;
@property (nonatomic, readonly) BOOL gpsEnabled;
Expand Down
Loading

0 comments on commit 49cde05

Please sign in to comment.