Skip to content

Commit

Permalink
Add Commandes listView
Browse files Browse the repository at this point in the history
  • Loading branch information
Élèves authored and Élèves committed Jan 14, 2013
1 parent c6581f1 commit adc75ab
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 6 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
url = https://github.com/ipodishima/MSToolTips.git
[submodule "SDWebImage"]
path = SDWebImage
url = git://github.com/rs/SDWebImage.git
url = https://github.com/rs/SDWebImage.git
[submodule "facebook-ios-sdk"]
path = facebook-ios-sdk
url = https://github.com/facebook/facebook-ios-sdk.git
14 changes: 14 additions & 0 deletions Projet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
9B499916163936B7000A24DA /* WineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B499915163936B7000A24DA /* WineViewController.m */; };
9B49991C163936EF000A24DA /* bouteille@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B49991B163936EF000A24DA /* bouteille@2x.png */; };
9B49991E16393726000A24DA /* mabout.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B49991D16393726000A24DA /* mabout.png */; };
9B9CE7F716A40696003E26B6 /* CommandesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9CE7F616A40696003E26B6 /* CommandesViewController.m */; };
9BFC82CF16392F70000C1600 /* iCarousel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFC82CE16392F70000C1600 /* iCarousel.m */; };
9BFC82D516392F7D000C1600 /* LBYouTubePlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFC82D216392F7D000C1600 /* LBYouTubePlayerController.m */; };
9BFC82D616392F7D000C1600 /* LBYouTubePlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BFC82D416392F7D000C1600 /* LBYouTubePlayerViewController.m */; };
Expand Down Expand Up @@ -120,6 +121,8 @@
9B499915163936B7000A24DA /* WineViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WineViewController.m; sourceTree = "<group>"; };
9B49991B163936EF000A24DA /* bouteille@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "bouteille@2x.png"; sourceTree = "<group>"; };
9B49991D16393726000A24DA /* mabout.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mabout.png; sourceTree = "<group>"; };
9B9CE7F516A40696003E26B6 /* CommandesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandesViewController.h; sourceTree = "<group>"; };
9B9CE7F616A40696003E26B6 /* CommandesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommandesViewController.m; sourceTree = "<group>"; };
9BFC82CD16392F70000C1600 /* iCarousel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iCarousel.h; sourceTree = "<group>"; };
9BFC82CE16392F70000C1600 /* iCarousel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iCarousel.m; sourceTree = "<group>"; };
9BFC82D116392F7D000C1600 /* LBYouTubePlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBYouTubePlayerController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -232,6 +235,15 @@
name = DetailWineView;
sourceTree = "<group>";
};
9B9CE7F816A40A93003E26B6 /* CommandesView */ = {
isa = PBXGroup;
children = (
9B9CE7F516A40696003E26B6 /* CommandesViewController.h */,
9B9CE7F616A40696003E26B6 /* CommandesViewController.m */,
);
name = CommandesView;
sourceTree = "<group>";
};
9BFC82CA16392F44000C1600 /* MSToolTips */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -358,6 +370,7 @@
E03C9815151A86590004D2FD /* TabBar */ = {
isa = PBXGroup;
children = (
9B9CE7F816A40A93003E26B6 /* CommandesView */,
9BFC82F516393310000C1600 /* WineView */,
E03C981E151A86590004D2FD /* AppDelegate.h */,
E03C981F151A86590004D2FD /* AppDelegate.m */,
Expand Down Expand Up @@ -524,6 +537,7 @@
82063BB21698CC1800C09A40 /* SDWebImagePrefetcher.m in Sources */,
82063BB31698CC1800C09A40 /* UIButton+WebCache.m in Sources */,
82063BB41698CC1800C09A40 /* UIImageView+WebCache.m in Sources */,
9B9CE7F716A40696003E26B6 /* CommandesViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
15 changes: 12 additions & 3 deletions TabBar/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "FifthViewController.h"
#import "SixthViewController.h"
#import "WineViewController.h"
#import "CommandesViewController.h"

@implementation AppDelegate
@synthesize session = _session;
Expand Down Expand Up @@ -55,6 +56,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
UITabBarItem *tabBarItem1 = [[UITabBarItem alloc] initWithTitle:@"List"
image:nil
tag:0];
UITabBarItem *tabBarItemCommande = [[UITabBarItem alloc] initWithTitle:@"Commandes"
image:nil
tag:0];


DataListViewController *dataListVC = [[DataListViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:dataListVC];
Expand All @@ -71,8 +76,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
navigationController.title = @"Cours";
[navigationController setNavigationBarHidden:NO];

ThirdViewController *thirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
thirdViewController.title = @"Commandes";
// ThirdViewController *thirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
// thirdViewController.title = @"Commandes";

CommandesViewController *commandeslist = [[CommandesViewController alloc] initWithStyle:UITableViewStylePlain];
commandeslist.tabBarItem = tabBarItemCommande;


FourthViewController *fourthViewController = [[FourthViewController alloc] initWithNibName:@"FourthViewController" bundle:nil];
fourthViewController.title = @"Quatrième";
Expand All @@ -86,7 +95,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
sixthViewController.tabBarItem = tabBarItemSixth;

_tabBarController.viewControllers = [NSArray arrayWithObjects: navController,
winenavigationController, navigationController, thirdViewController, fourthViewController, fifthViewController, sixthViewController, nil];
winenavigationController, navigationController, commandeslist, fourthViewController, fifthViewController, sixthViewController, nil];

[_tabBarController.tabBar setSelectedImageTintColor:[UIColor grayColor]];

Expand Down
18 changes: 18 additions & 0 deletions TabBar/CommandesViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// CommandesViewController.h
// Projet
//
// Created by Élèves on 14/01/13.
//
//

#import <UIKit/UIKit.h>
#import "DetailListViewController.h"
#import "CustomCell.h"
#import "AppDelegate.h"
@interface CommandesViewController : UITableViewController
{
NSArray *_dataToShow;
NSArray *_dataToDraw;
}
@end
162 changes: 162 additions & 0 deletions TabBar/CommandesViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#import "CommandesViewController.h"



@interface CommandesViewController ()
@property (strong, nonatomic) IBOutlet UIButton *buttonLoginLogout;
@end

@implementation CommandesViewController

- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
@synthesize buttonLoginLogout = _buttonLoginLogout;
- (void)viewDidLoad
{
self.title=@"List";
_dataToShow = [[NSArray alloc] initWithObjects:@"Mon Profil", @"Videos", @"A propos", nil];
_dataToDraw = [[NSArray alloc] initWithObjects: @"17-bar-chart.png",@"17-bar-chart.png",@"17-bar-chart.png", nil];
// UIView *footer = [[UIView alloc] initWithFrame:CGRectZero];
// self.tableView.tableFooterView =footer;
[super viewDidLoad];

_buttonLoginLogout = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[_buttonLoginLogout setFrame:CGRectMake(30, 150, 280, 30)];
[_buttonLoginLogout setTitle:@"Facebook" forState:UIControlStateNormal];
[_buttonLoginLogout addTarget:self action:@selector(buttonClickHandler:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_buttonLoginLogout];
[self updateView];


AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
if (!appDelegate.session.isOpen) {
// create a fresh session object
appDelegate.session = [[FBSession alloc] init];

// if we don't have a cached token, a call to open here would cause UX for login to
// occur; we don't want that to happen unless the user clicks the login button, and so
// we check here to make sure we have a token before calling open
if (appDelegate.session.state == FBSessionStateCreatedTokenLoaded) {
// even though we had a cached token, we need to login to make the session usable
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// we recurse here, in order to update buttons and labels
[self updateView];
}];
}
}


// 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;
}
- (void)updateView {
// get the app delegate, so that we can reference the session property
AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
if (appDelegate.session.isOpen) {
// valid account UI is shown whenever the session is open
[self.buttonLoginLogout setTitle:@"Log out" forState:UIControlStateNormal];
// [self.textNoteOrLink setText:[NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@",
// appDelegate.session.accessToken]];
} else {
// login-needed account UI is shown whenever the session is closed
[self.buttonLoginLogout setTitle:@"Log in" forState:UIControlStateNormal];
// [self.textNoteOrLink setText:@"Login to create a link to fetch account data"];
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#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 3;
}

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

static NSString *CellIdentifier = @"CustomCell";

CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}


UIImage *image = [UIImage imageNamed:[_dataToDraw objectAtIndex:[indexPath row]]];

// cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.imageView.image = image;

cell.myLabel.text = [_dataToShow objectAtIndex:[indexPath row]];

return cell;

}


#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// cell.accessoryType = UITableViewCellAccessoryCheckmark;



}

#pragma mark - FBSession logic
// handler for button click, logs sessions in or out
- (IBAction)buttonClickHandler:(id)sender {
AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];

// this button's job is to flip-flop the session from open to closed
if (appDelegate.session.isOpen) {
[appDelegate.session closeAndClearTokenInformation];

} else {
if (appDelegate.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
appDelegate.session = [[FBSession alloc] init];
}

// if the session isn't open, let's open it now and present the login UX to the user
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// and here we make sure to update our UX according to the new session state
[self updateView];
}];
}
}
@end
9 changes: 7 additions & 2 deletions TabBar/DetailWineViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,26 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

- (void)viewDidLoad
{
self.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
_label = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 3, CGRectGetWidth(self.view.bounds)-10.0, 15.0)];
_label.text = [NSString stringWithFormat:@"Nom: %s",[_wineAAfficher.name UTF8String ]];
_label.backgroundColor =[UIColor colorWithRed:204.00/255.0 green:1.0 blue:1.0 alpha:0.4];
[self.view addSubview:_label];

_labelage = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 21.0, CGRectGetWidth(self.view.bounds)-10.0, 15.0)];
_labelage.text = [NSString stringWithFormat:@"Date: %s",[_wineAAfficher.age UTF8String ]];
_labelage.backgroundColor =[UIColor colorWithRed:204.00/255.0 green:1.0 blue:1.0 alpha:0.4];
[self.view addSubview:_labelage];
_labeldom = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 39.0, CGRectGetWidth(self.view.bounds)-10.0, 15.0)];
_labeldom.text = [NSString stringWithFormat:@"Domaine: %s",[_wineAAfficher.domaine UTF8String ]];
_labeldom.backgroundColor =[UIColor colorWithRed:204.00/255.0 green:1.0 blue:1.0 alpha:0.4];
[self.view addSubview:_labeldom];

_textView = [[UITextView alloc] initWithFrame:CGRectMake(10.0, 57.0, CGRectGetWidth(self.view.bounds)-20.0, 150.0)];
_textView.textColor = [UIColor blackColor];
_textView.font = [UIFont boldSystemFontOfSize:15.0];
_textView.backgroundColor = [UIColor grayColor];
_textView.backgroundColor = [UIColor colorWithRed:204.00/255.0 green:1.0 blue:1.0 alpha:0.4];

_textView.editable = false;
_textView.text = [NSString stringWithFormat:@"%s",[_wineAAfficher.apropos UTF8String ]];
[self.view addSubview:_textView];
Expand All @@ -65,7 +70,7 @@ - (void) commander:(id)sender

UIViewController *controllerToSelect = nil;
for (UIViewController *controller in tabController.viewControllers)
if([controller isKindOfClass:NSClassFromString(@"ThirdViewController")])
if([controller isKindOfClass:NSClassFromString(@"CommandesViewController")])
{
controllerToSelect = controller;
break;
Expand Down

0 comments on commit adc75ab

Please sign in to comment.