diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings new file mode 100644 index 0000000..975a21c --- /dev/null +++ b/en.lproj/Localizable.strings @@ -0,0 +1,10 @@ +/* + LocalizableString.strings + iTunesSearch + + Created by Fernando on 3/10/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ + +"feature-movie"="movie"; +"song"="song"; \ No newline at end of file diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings new file mode 100644 index 0000000..af0066b --- /dev/null +++ b/fr.lproj/Localizable.strings @@ -0,0 +1,10 @@ +/* + LocalizableString.strings + iTunesSearch + + Created by Fernando on 3/10/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ + +"feature-movie"="Le Mouvê"; +"song"="La Musiquê"; \ No newline at end of file diff --git a/iTunesSearch.xcodeproj/project.pbxproj b/iTunesSearch.xcodeproj/project.pbxproj index 79e06d7..fb1d7a6 100644 --- a/iTunesSearch.xcodeproj/project.pbxproj +++ b/iTunesSearch.xcodeproj/project.pbxproj @@ -13,10 +13,16 @@ 92C21CC11AAE757A0052ABE6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92C21CC01AAE757A0052ABE6 /* Images.xcassets */; }; 92C21CD01AAE757A0052ABE6 /* iTunesSearchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CCF1AAE757A0052ABE6 /* iTunesSearchTests.m */; }; 92C21CDB1AAE75B30052ABE6 /* iTunesManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CDA1AAE75B30052ABE6 /* iTunesManager.m */; }; - 92C21CDD1AAE75DC0052ABE6 /* TableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 92C21CDC1AAE75DC0052ABE6 /* TableView.xib */; }; 92C21CE11AAE76930052ABE6 /* TableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CDF1AAE76930052ABE6 /* TableViewCell.m */; }; 92C21CE21AAE76930052ABE6 /* TableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 92C21CE01AAE76930052ABE6 /* TableViewCell.xib */; }; 92C21CE81AAE858E0052ABE6 /* Filme.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CE71AAE858E0052ABE6 /* Filme.m */; }; + D427D3491AB24030009954B9 /* Desc.m in Sources */ = {isa = PBXBuildFile; fileRef = D427D3471AB24030009954B9 /* Desc.m */; }; + D427D34A1AB24030009954B9 /* Desc.xib in Resources */ = {isa = PBXBuildFile; fileRef = D427D3481AB24030009954B9 /* Desc.xib */; }; + D45A99D91AAF85980020E5C2 /* TableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D45A99DB1AAF85980020E5C2 /* TableView.xib */; }; + D45A99E01AAF89A80020E5C2 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D45A99E21AAF89A80020E5C2 /* Localizable.strings */; }; + D45A99E71AB0C43D0020E5C2 /* Music.m in Sources */ = {isa = PBXBuildFile; fileRef = D45A99E61AB0C43D0020E5C2 /* Music.m */; }; + D45A99EA1AB0C4B90020E5C2 /* Podcasts.m in Sources */ = {isa = PBXBuildFile; fileRef = D45A99E91AB0C4B90020E5C2 /* Podcasts.m */; }; + D45E621A1AB38A45001859F0 /* Mae.m in Sources */ = {isa = PBXBuildFile; fileRef = D45E62191AB38A45001859F0 /* Mae.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -43,12 +49,26 @@ 92C21CCF1AAE757A0052ABE6 /* iTunesSearchTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iTunesSearchTests.m; sourceTree = ""; }; 92C21CD91AAE75B30052ABE6 /* iTunesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTunesManager.h; sourceTree = ""; }; 92C21CDA1AAE75B30052ABE6 /* iTunesManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTunesManager.m; sourceTree = ""; }; - 92C21CDC1AAE75DC0052ABE6 /* TableView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableView.xib; sourceTree = ""; }; 92C21CDE1AAE76930052ABE6 /* TableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewCell.h; sourceTree = ""; }; 92C21CDF1AAE76930052ABE6 /* TableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewCell.m; sourceTree = ""; }; 92C21CE01AAE76930052ABE6 /* TableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableViewCell.xib; sourceTree = ""; }; 92C21CE61AAE858E0052ABE6 /* Filme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Filme.h; path = Entidades/Filme.h; sourceTree = ""; }; 92C21CE71AAE858E0052ABE6 /* Filme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Filme.m; path = Entidades/Filme.m; sourceTree = ""; }; + D427D3461AB24030009954B9 /* Desc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Desc.h; sourceTree = ""; }; + D427D3471AB24030009954B9 /* Desc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Desc.m; sourceTree = ""; }; + D427D3481AB24030009954B9 /* Desc.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Desc.xib; sourceTree = ""; }; + D45A99DA1AAF85980020E5C2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/TableView.xib; sourceTree = ""; }; + D45A99DC1AAF85AD0020E5C2 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/TableView.strings; sourceTree = ""; }; + D45A99DD1AAF871C0020E5C2 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/TableView.strings; sourceTree = ""; }; + D45A99E11AAF89A80020E5C2 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = ""; }; + D45A99E31AAF89AB0020E5C2 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; + D45A99E41AAF89AC0020E5C2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + D45A99E51AB0C43D0020E5C2 /* Music.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Music.h; path = Entidades/Music.h; sourceTree = ""; }; + D45A99E61AB0C43D0020E5C2 /* Music.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Music.m; path = Entidades/Music.m; sourceTree = ""; }; + D45A99E81AB0C4B90020E5C2 /* Podcasts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Podcasts.h; path = Entidades/Podcasts.h; sourceTree = ""; }; + D45A99E91AB0C4B90020E5C2 /* Podcasts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Podcasts.m; path = Entidades/Podcasts.m; sourceTree = ""; }; + D45E62181AB38A45001859F0 /* Mae.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mae.h; path = Entidades/Mae.h; sourceTree = ""; }; + D45E62191AB38A45001859F0 /* Mae.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Mae.m; path = Entidades/Mae.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -72,6 +92,7 @@ 92C21CA71AAE757A0052ABE6 = { isa = PBXGroup; children = ( + D45A99E21AAF89A80020E5C2 /* Localizable.strings */, 92C21CB21AAE757A0052ABE6 /* iTunesSearch */, 92C21CCC1AAE757A0052ABE6 /* iTunesSearchTests */, 92C21CB11AAE757A0052ABE6 /* Products */, @@ -94,9 +115,12 @@ 92C21CE91AAE859A0052ABE6 /* Entidades */, 92C21CB71AAE757A0052ABE6 /* AppDelegate.h */, 92C21CB81AAE757A0052ABE6 /* AppDelegate.m */, + D427D3461AB24030009954B9 /* Desc.h */, + D427D3471AB24030009954B9 /* Desc.m */, + D427D3481AB24030009954B9 /* Desc.xib */, 92C21CBA1AAE757A0052ABE6 /* TableViewController.h */, 92C21CBB1AAE757A0052ABE6 /* TableViewController.m */, - 92C21CDC1AAE75DC0052ABE6 /* TableView.xib */, + D45A99DB1AAF85980020E5C2 /* TableView.xib */, 92C21CD91AAE75B30052ABE6 /* iTunesManager.h */, 92C21CDA1AAE75B30052ABE6 /* iTunesManager.m */, 92C21CC01AAE757A0052ABE6 /* Images.xcassets */, @@ -146,6 +170,12 @@ children = ( 92C21CE61AAE858E0052ABE6 /* Filme.h */, 92C21CE71AAE858E0052ABE6 /* Filme.m */, + D45A99E51AB0C43D0020E5C2 /* Music.h */, + D45A99E61AB0C43D0020E5C2 /* Music.m */, + D45A99E81AB0C4B90020E5C2 /* Podcasts.h */, + D45A99E91AB0C4B90020E5C2 /* Podcasts.m */, + D45E62181AB38A45001859F0 /* Mae.h */, + D45E62191AB38A45001859F0 /* Mae.m */, ); name = Entidades; sourceTree = ""; @@ -213,6 +243,7 @@ knownRegions = ( en, Base, + fr, ); mainGroup = 92C21CA71AAE757A0052ABE6; productRefGroup = 92C21CB11AAE757A0052ABE6 /* Products */; @@ -231,8 +262,10 @@ buildActionMask = 2147483647; files = ( 92C21CC11AAE757A0052ABE6 /* Images.xcassets in Resources */, + D427D34A1AB24030009954B9 /* Desc.xib in Resources */, 92C21CE21AAE76930052ABE6 /* TableViewCell.xib in Resources */, - 92C21CDD1AAE75DC0052ABE6 /* TableView.xib in Resources */, + D45A99E01AAF89A80020E5C2 /* Localizable.strings in Resources */, + D45A99D91AAF85980020E5C2 /* TableView.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -250,12 +283,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D45A99E71AB0C43D0020E5C2 /* Music.m in Sources */, 92C21CBC1AAE757A0052ABE6 /* TableViewController.m in Sources */, 92C21CDB1AAE75B30052ABE6 /* iTunesManager.m in Sources */, 92C21CB91AAE757A0052ABE6 /* AppDelegate.m in Sources */, 92C21CE81AAE858E0052ABE6 /* Filme.m in Sources */, 92C21CE11AAE76930052ABE6 /* TableViewCell.m in Sources */, + D45A99EA1AB0C4B90020E5C2 /* Podcasts.m in Sources */, + D427D3491AB24030009954B9 /* Desc.m in Sources */, 92C21CB61AAE757A0052ABE6 /* main.m in Sources */, + D45E621A1AB38A45001859F0 /* Mae.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -277,6 +314,29 @@ }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + D45A99DB1AAF85980020E5C2 /* TableView.xib */ = { + isa = PBXVariantGroup; + children = ( + D45A99DA1AAF85980020E5C2 /* Base */, + D45A99DC1AAF85AD0020E5C2 /* pt */, + D45A99DD1AAF871C0020E5C2 /* fr */, + ); + name = TableView.xib; + sourceTree = ""; + }; + D45A99E21AAF89A80020E5C2 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + D45A99E11AAF89A80020E5C2 /* pt */, + D45A99E31AAF89AB0020E5C2 /* fr */, + D45A99E41AAF89AC0020E5C2 /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 92C21CD11AAE757A0052ABE6 /* Debug */ = { isa = XCBuildConfiguration; diff --git a/iTunesSearch/AppDelegate.h b/iTunesSearch/AppDelegate.h index b8e3142..876b876 100644 --- a/iTunesSearch/AppDelegate.h +++ b/iTunesSearch/AppDelegate.h @@ -11,7 +11,7 @@ @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; - +@property UINavigationController *navigation; @end diff --git a/iTunesSearch/AppDelegate.m b/iTunesSearch/AppDelegate.m index d513fd8..0822fef 100644 --- a/iTunesSearch/AppDelegate.m +++ b/iTunesSearch/AppDelegate.m @@ -10,6 +10,7 @@ #warning Classe importada para uso no metodo de inicilizacao da App #import "TableViewController.h" +#import "Desc.h" @interface AppDelegate () @@ -26,10 +27,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( self.window.backgroundColor = [UIColor whiteColor]; #warning Adicionado codigo para iniciar com a interface do TableView -// TableViewController *tvc = [[TableViewController alloc] initWithNibName:@"TableView" bundle:nil]; + // TableViewController *tvc = [[TableViewController alloc] initWithNibName:@"TableView" bundle:nil]; TableViewController *tvc = [[TableViewController alloc] init]; - [self.window setRootViewController:tvc]; + + UINavigationController *tableViewNavigation = [[UINavigationController alloc]initWithRootViewController:tvc]; + + + + [self.window setRootViewController:tableViewNavigation]; [self.window makeKeyAndVisible]; + self.navigation = [[UINavigationController alloc] initWithRootViewController:[[Desc alloc] initWithNibName:@"Desc" bundle:nil]]; + + [self.window makeKeyAndVisible]; + + // self.window.rootViewController = self.navigation; + return YES; } diff --git a/iTunesSearch/Base.lproj/TableView.xib b/iTunesSearch/Base.lproj/TableView.xib new file mode 100644 index 0000000..6b309e9 --- /dev/null +++ b/iTunesSearch/Base.lproj/TableView.xib @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iTunesSearch/Desc.h b/iTunesSearch/Desc.h new file mode 100644 index 0000000..2638482 --- /dev/null +++ b/iTunesSearch/Desc.h @@ -0,0 +1,26 @@ +// +// Desc.h +// iTunesSearch +// +// Created by Fernando on 3/12/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Filme.h" +#import "Music.h" +#import "Podcasts.h" + +@interface Desc : UIViewController + +@property (weak, nonatomic) IBOutlet UIImageView *imgDesc; +@property (weak, nonatomic) IBOutlet UILabel *nomeDesc; +@property (weak, nonatomic) IBOutlet UILabel *artistaDesc; + +@property Mae *m; + + + + +-(void) carregaImagens:(NSString *)url; +@end diff --git a/iTunesSearch/Desc.m b/iTunesSearch/Desc.m new file mode 100644 index 0000000..12ad90c --- /dev/null +++ b/iTunesSearch/Desc.m @@ -0,0 +1,72 @@ +// +// Desc.m +// iTunesSearch +// +// Created by Fernando on 3/12/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Desc.h" +#import "TableViewCell.h" + +@interface Desc () + +@end + +@implementation Desc +@synthesize imgDesc,nomeDesc,artistaDesc,m; + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + + +} + +-(void)viewWillAppear:(BOOL)animated{ + artistaDesc.text = m.artista; + nomeDesc.text = m.nome; + [self carregaImagens:m.img]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +-(void) carregaImagens:(NSString *)url +{ + NSData * imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + imgDesc.image = image; +} + +// +//-(void) update1:(Filme *)objeto{ +// [nomeDesc setText:objeto.nome]; +// [artistaDesc setText:objeto.artista]; +// [self carregaImagens:objeto.img]; +//} +// +//-(void) update2:(Music *)objeto{ +// [nomeDesc setText:objeto.nome]; +// [artistaDesc setText:objeto.artista]; +// [self carregaImagens:objeto.img]; +//} +// +//-(void) update0:(Podcasts *)objeto{ +// [nomeDesc setText:objeto.nome]; +// [artistaDesc setText:objeto.artista]; +// [self carregaImagens:objeto.img]; +//} +/* +#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. +} +*/ + +@end diff --git a/iTunesSearch/Desc.xib b/iTunesSearch/Desc.xib new file mode 100644 index 0000000..dfc1ca1 --- /dev/null +++ b/iTunesSearch/Desc.xib @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iTunesSearch/Entidades/Filme.h b/iTunesSearch/Entidades/Filme.h index eb126dc..e921618 100644 --- a/iTunesSearch/Entidades/Filme.h +++ b/iTunesSearch/Entidades/Filme.h @@ -7,14 +7,10 @@ // #import +#import "Mae.h" + +@interface Filme : Mae -@interface Filme : NSObject -@property (nonatomic, strong) NSString *nome; -@property (nonatomic, strong) NSString *trackId; -@property (nonatomic, strong) NSString *artista; -@property (nonatomic, strong) NSString *duracao; -@property (nonatomic, strong) NSString *genero; -@property (nonatomic, strong) NSString *pais; @end diff --git a/iTunesSearch/Entidades/Mae.h b/iTunesSearch/Entidades/Mae.h new file mode 100644 index 0000000..6540dfa --- /dev/null +++ b/iTunesSearch/Entidades/Mae.h @@ -0,0 +1,23 @@ +// +// Mae.h +// iTunesSearch +// +// Created by Fernando on 3/13/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import + +@interface Mae : NSObject + +@property (nonatomic, strong) NSString *nome; +@property (nonatomic, strong) NSString *trackId; +@property (nonatomic, strong) NSString *artista; +@property (nonatomic, strong) NSNumber *duracao; +@property (nonatomic, strong) NSString *genero; +@property (nonatomic, strong) NSString *pais; +@property (nonatomic, strong) NSString *tipo; +@property (nonatomic, strong) NSString *img; + + +@end diff --git a/iTunesSearch/Entidades/Mae.m b/iTunesSearch/Entidades/Mae.m new file mode 100644 index 0000000..604b794 --- /dev/null +++ b/iTunesSearch/Entidades/Mae.m @@ -0,0 +1,13 @@ +// +// Mae.m +// iTunesSearch +// +// Created by Fernando on 3/13/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Mae.h" + +@implementation Mae + +@end diff --git a/iTunesSearch/Entidades/Music.h b/iTunesSearch/Entidades/Music.h new file mode 100644 index 0000000..b0c3852 --- /dev/null +++ b/iTunesSearch/Entidades/Music.h @@ -0,0 +1,17 @@ +// +// Music.h +// iTunesSearch +// +// Created by Fernando on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Mae.h" + +@interface Music : Mae + + + + +@end diff --git a/iTunesSearch/Entidades/Music.m b/iTunesSearch/Entidades/Music.m new file mode 100644 index 0000000..57d90dd --- /dev/null +++ b/iTunesSearch/Entidades/Music.m @@ -0,0 +1,14 @@ +// +// Music.m +// iTunesSearch +// +// Created by Fernando on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Music.h" + +@implementation Music + + +@end diff --git a/iTunesSearch/Entidades/Podcasts.h b/iTunesSearch/Entidades/Podcasts.h new file mode 100644 index 0000000..2d08adb --- /dev/null +++ b/iTunesSearch/Entidades/Podcasts.h @@ -0,0 +1,16 @@ +// +// Podcasts.h +// iTunesSearch +// +// Created by Fernando on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Mae.h" +@interface Podcasts : Mae + + + + +@end diff --git a/iTunesSearch/Entidades/Podcasts.m b/iTunesSearch/Entidades/Podcasts.m new file mode 100644 index 0000000..97da76d --- /dev/null +++ b/iTunesSearch/Entidades/Podcasts.m @@ -0,0 +1,15 @@ +// +// Podcasts.m +// iTunesSearch +// +// Created by Fernando on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Podcasts.h" + +@implementation Podcasts + + + +@end diff --git a/iTunesSearch/TableView.xib b/iTunesSearch/TableView.xib deleted file mode 100644 index 55f128c..0000000 --- a/iTunesSearch/TableView.xib +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iTunesSearch/TableViewCell.h b/iTunesSearch/TableViewCell.h index b630349..42a4d95 100644 --- a/iTunesSearch/TableViewCell.h +++ b/iTunesSearch/TableViewCell.h @@ -12,6 +12,11 @@ @property (weak, nonatomic) IBOutlet UILabel *nome; @property (weak, nonatomic) IBOutlet UILabel *tipo; +@property (weak, nonatomic) IBOutlet UILabel *artista; +@property (weak, nonatomic) IBOutlet UIImageView *imageView; +@property (weak, nonatomic) IBOutlet UILabel *pais; +//@property (weak, nonatomic) IBOutlet UILabel *duracao; +-(void) carregaImagens:(NSString *)url; @end diff --git a/iTunesSearch/TableViewCell.m b/iTunesSearch/TableViewCell.m index ffac89c..3780dbf 100644 --- a/iTunesSearch/TableViewCell.m +++ b/iTunesSearch/TableViewCell.m @@ -9,6 +9,7 @@ #import "TableViewCell.h" @implementation TableViewCell +@synthesize imageView; - (void)awakeFromNib { // Initialization code @@ -20,4 +21,12 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated { // Configure the view for the selected state } +-(void) carregaImagens:(NSString *)url +{ + NSData * imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + imageView.image = image; + +} + @end diff --git a/iTunesSearch/TableViewCell.xib b/iTunesSearch/TableViewCell.xib index bf8bd3f..0ad184c 100644 --- a/iTunesSearch/TableViewCell.xib +++ b/iTunesSearch/TableViewCell.xib @@ -1,5 +1,5 @@ - + @@ -7,40 +7,93 @@ - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/iTunesSearch/TableViewController.h b/iTunesSearch/TableViewController.h index 0cbb5c4..eae67b0 100644 --- a/iTunesSearch/TableViewController.h +++ b/iTunesSearch/TableViewController.h @@ -12,6 +12,9 @@ @property (strong, nonatomic) IBOutlet UITableView *tableview; +@property (weak, nonatomic) IBOutlet UISearchBar *search; + +- (IBAction)buscar:(id)sender; @end diff --git a/iTunesSearch/TableViewController.m b/iTunesSearch/TableViewController.m index f689980..e724399 100644 --- a/iTunesSearch/TableViewController.m +++ b/iTunesSearch/TableViewController.m @@ -10,6 +10,9 @@ #import "TableViewCell.h" #import "iTunesManager.h" #import "Entidades/Filme.h" +#import "Entidades/Podcasts.h" +#import "Entidades/Music.h" +#import "Desc.h" @interface TableViewController () { NSArray *midias; @@ -19,6 +22,9 @@ @interface TableViewController () { @implementation TableViewController +@synthesize search; + +iTunesManager *itunes; - (void)viewDidLoad { @@ -26,12 +32,12 @@ - (void)viewDidLoad { UINib *nib = [UINib nibWithNibName:@"TableViewCell" bundle:nil]; [self.tableview registerNib:nib forCellReuseIdentifier:@"celulaPadrao"]; + [search setDelegate:self]; + + itunes = [iTunesManager sharedInstance]; - iTunesManager *itunes = [iTunesManager sharedInstance]; - midias = [itunes buscarMidias:@"Apple"]; -#warning Necessario para que a table view tenha um espaco em relacao ao topo, pois caso contrario o texto ficara atras da barra superior - self.tableview.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableview.bounds.size.width, 15.f)]; + } - (void)didReceiveMemoryWarning { @@ -42,27 +48,132 @@ - (void)didReceiveMemoryWarning { #pragma mark - Metodos do UITableViewDataSource -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; + //NSUInteger qtd = midias.count; + + return [midias count]; +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + + + Desc *dView = [[Desc alloc]init]; + + if (indexPath.section == 0){ + Podcasts *x = [[midias objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; + [self.navigationController pushViewController:dView animated:YES]; + dView.m = x; + } + if (indexPath.section == 1){ + Filme *x = [[midias objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; + [self.navigationController pushViewController:dView animated:YES]; + dView.m = x; + } + if (indexPath.section == 0){ + Music *x = [[midias objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; + [self.navigationController pushViewController:dView animated:YES]; + dView.m = x; + } + } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return [midias count]; + NSUInteger i=0; + if (section==0){ + i = [[midias objectAtIndex:0] count]; + + } + if (section==1){ + i = [[midias objectAtIndex:1] count]; + + } + if (section==2){ + i = [[midias objectAtIndex:2] count]; + } + + return i; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + TableViewCell *celula = [self.tableview dequeueReusableCellWithIdentifier:@"celulaPadrao"]; - Filme *filme = [midias objectAtIndex:indexPath.row]; + + + if (indexPath.section == 0){ + + Podcasts *podcast = [[midias objectAtIndex:0] objectAtIndex:indexPath.row]; + + [celula.nome setText:podcast.nome]; + [celula.tipo setText:NSLocalizedString(podcast.tipo,nil)]; + [celula.artista setText:podcast.artista]; + [celula.pais setText:podcast.pais]; + [celula carregaImagens:podcast.img]; + // [celula.duracao setText:[podcast.duracao stringValue]]; + } + + if (indexPath.section == 1){ + + Filme *filme = [[midias objectAtIndex:1] objectAtIndex:indexPath.row]; + + [celula.nome setText:filme.nome]; + [celula.tipo setText:NSLocalizedString(filme.tipo,nil)]; + [celula.artista setText:filme.artista]; + [celula.pais setText:filme.pais]; + [celula carregaImagens:filme.img]; + // [celula.duracao setText:[filme.duracao stringValue]]; + } + + if (indexPath.section == 2){ + + Music *music = [[midias objectAtIndex:2] objectAtIndex:indexPath.row]; + + [celula.nome setText:music.nome]; + [celula.tipo setText:NSLocalizedString(music.tipo,nil)]; + [celula.artista setText:music.artista]; + [celula.pais setText:music.pais]; + [celula carregaImagens:music.img]; + //[celula.duracao setText:[music.duracao stringValue]]; + } - [celula.nome setText:filme.nome]; - [celula.tipo setText:@"Filme"]; return celula; } +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + NSString *sectionName; + + switch (section) + { + case 0: + sectionName =@"Podcast"; + break; + case 1: + sectionName = @"Movie"; + break; + case 2: + sectionName = @"Music"; + break; + default: + sectionName = @""; + break; + } + return sectionName; +} + + -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 70; } +- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar +{ + midias = [itunes buscarMidias:searchBar.text]; + [self.tableview reloadData]; + +} +- (IBAction)buscar:(id)sender { + [self searchBarSearchButtonClicked:search]; +} @end diff --git a/iTunesSearch/fr.lproj/TableView.strings b/iTunesSearch/fr.lproj/TableView.strings new file mode 100644 index 0000000..b95ec58 --- /dev/null +++ b/iTunesSearch/fr.lproj/TableView.strings @@ -0,0 +1,3 @@ + +/* Class = "UIButton"; normalTitle = "Search"; ObjectID = "5WQ-PH-NlX"; */ +"5WQ-PH-NlX.normalTitle" = "Recherche"; diff --git a/iTunesSearch/iTunesManager.m b/iTunesSearch/iTunesManager.m index e2babda..00c5465 100644 --- a/iTunesSearch/iTunesManager.m +++ b/iTunesSearch/iTunesManager.m @@ -8,6 +8,12 @@ #import "iTunesManager.h" #import "Entidades/Filme.h" +#import "Entidades/Music.h" +#import "Entidades/Podcasts.h" + + + +NSMutableArray *sect; @implementation iTunesManager @@ -34,7 +40,7 @@ - (NSArray *)buscarMidias:(NSString *)termo { termo = @""; } - NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&media=movie", termo]; + NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&media=all", termo]; NSData *jsonData = [NSData dataWithContentsOfURL: [NSURL URLWithString:url]]; NSError *error; @@ -48,19 +54,62 @@ - (NSArray *)buscarMidias:(NSString *)termo { NSArray *resultados = [resultado objectForKey:@"results"]; NSMutableArray *filmes = [[NSMutableArray alloc] init]; - + NSMutableArray *musicas = [[NSMutableArray alloc]init]; + NSMutableArray *podcasts = [[NSMutableArray alloc]init]; + for (NSDictionary *item in resultados) { - Filme *filme = [[Filme alloc] init]; - [filme setNome:[item objectForKey:@"trackName"]]; - [filme setTrackId:[item objectForKey:@"trackId"]]; - [filme setArtista:[item objectForKey:@"artistName"]]; - [filme setDuracao:[item objectForKey:@"trackTimeMillis"]]; - [filme setGenero:[item objectForKey:@"primaryGenreName"]]; - [filme setPais:[item objectForKey:@"country"]]; - [filmes addObject:filme]; + + NSString *tipo = [item objectForKey:@"kind"]; + + if ([tipo isEqualToString: @"feature-movie"]){ + + Filme *filme = [[Filme alloc] init]; + [filme setNome:[item objectForKey:@"trackName"]]; + [filme setTrackId:[item objectForKey:@"trackId"]]; + [filme setArtista:[item objectForKey:@"artistName"]]; + [filme setDuracao:[item objectForKey:@"trackTimeMillis"]]; + [filme setGenero:[item objectForKey:@"primaryGenreName"]]; + [filme setPais:[item objectForKey:@"country"]]; + [filme setTipo:[item objectForKey:@"kind"]]; + [filme setImg:[item objectForKey:@"artworkUrl100"]]; + [filmes addObject:filme]; + + } + if ([tipo isEqualToString: @"song"]){ + + Music *musica = [[Music alloc] init]; + [musica setNome:[item objectForKey:@"trackName"]]; + [musica setTrackId:[item objectForKey:@"trackId"]]; + [musica setArtista:[item objectForKey:@"artistName"]]; + [musica setDuracao:[item objectForKey:@"trackTimeMillis"]]; + [musica setGenero:[item objectForKey:@"primaryGenreName"]]; + [musica setPais:[item objectForKey:@"country"]]; + [musica setTipo:[item objectForKey:@"kind"]]; + [musica setImg:[item objectForKey:@"artworkUrl100"]]; + [musicas addObject:musica]; + + } + + if ([tipo isEqualToString: @"podcast"]){ + + Podcasts *podcast = [[Podcasts alloc] init]; + [podcast setNome:[item objectForKey:@"trackName"]]; + [podcast setTrackId:[item objectForKey:@"trackId"]]; + [podcast setArtista:[item objectForKey:@"artistName"]]; + [podcast setDuracao:[item objectForKey:@"trackTimeMillis"]]; + [podcast setGenero:[item objectForKey:@"primaryGenreName"]]; + [podcast setPais:[item objectForKey:@"country"]]; + [podcast setTipo:[item objectForKey:@"kind"]]; + [podcast setImg:[item objectForKey:@"artworkUrl100"]]; + [podcasts addObject:podcast]; + + } + } - return filmes; + + NSArray *midiasArray = [[NSArray alloc]initWithObjects:podcasts,filmes,musicas, nil]; + return midiasArray; } diff --git a/iTunesSearch/pt.lproj/TableView.strings b/iTunesSearch/pt.lproj/TableView.strings new file mode 100644 index 0000000..8e31c67 --- /dev/null +++ b/iTunesSearch/pt.lproj/TableView.strings @@ -0,0 +1,3 @@ + +/* Class = "UIButton"; normalTitle = "Procurar"; ObjectID = "5WQ-PH-NlX"; */ +"5WQ-PH-NlX.normalTitle" = "Procurar"; diff --git a/pt.lproj/Localizable.strings b/pt.lproj/Localizable.strings new file mode 100644 index 0000000..aaad894 --- /dev/null +++ b/pt.lproj/Localizable.strings @@ -0,0 +1,9 @@ +/* + LocalizableString.strings + iTunesSearch + + Created by Fernando on 3/10/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ +"feature-movie"="Filme"; +"song"="Musica"; \ No newline at end of file