diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings new file mode 100644 index 0000000..bcb4717 --- /dev/null +++ b/en.lproj/Localizable.strings @@ -0,0 +1,9 @@ +/* + LocalizableString.strings + iTunesSearch + + Created by João Vitor dos Santos Schimmelpfeng on 10/03/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ +"movie" = "Movie"; +"song" = "Music"; \ No newline at end of file diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings new file mode 100644 index 0000000..ad3858a --- /dev/null +++ b/fr.lproj/Localizable.strings @@ -0,0 +1,9 @@ +/* + LocalizableString.strings + iTunesSearch + + Created by João Vitor dos Santos Schimmelpfeng on 10/03/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ +"movie" = "Le Movie"; +"song"= "La musique"; \ No newline at end of file diff --git a/iTunesSearch.xcodeproj/project.pbxproj b/iTunesSearch.xcodeproj/project.pbxproj index 79e06d7..41964f9 100644 --- a/iTunesSearch.xcodeproj/project.pbxproj +++ b/iTunesSearch.xcodeproj/project.pbxproj @@ -13,10 +13,13 @@ 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 */; }; + 92C21CE81AAE858E0052ABE6 /* Midia.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CE71AAE858E0052ABE6 /* Midia.m */; }; + E668D1E21AAF85690043A4ED /* TableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E668D1E41AAF85690043A4ED /* TableView.xib */; }; + E668D1E91AAF8A0F0043A4ED /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E668D1EB1AAF8A0F0043A4ED /* Localizable.strings */; }; + E694DF331AB0CAB200D95B25 /* showView.m in Sources */ = {isa = PBXBuildFile; fileRef = E694DF311AB0CAB200D95B25 /* showView.m */; }; + E694DF341AB0CAB200D95B25 /* showView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E694DF321AB0CAB200D95B25 /* showView.xib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -43,12 +46,20 @@ 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 = ""; }; + 92C21CE61AAE858E0052ABE6 /* Midia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Midia.h; path = Entidades/Midia.h; sourceTree = ""; }; + 92C21CE71AAE858E0052ABE6 /* Midia.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Midia.m; path = Entidades/Midia.m; sourceTree = ""; }; + E668D1E31AAF85690043A4ED /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/TableView.xib; sourceTree = ""; }; + E668D1E51AAF85890043A4ED /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/TableView.strings; sourceTree = ""; }; + E668D1E61AAF87150043A4ED /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/TableView.strings; sourceTree = ""; }; + E668D1EC1AAF8A120043A4ED /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + E668D1ED1AAF8A170043A4ED /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = ""; }; + E668D1EE1AAF8A180043A4ED /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; + E694DF301AB0CAB200D95B25 /* showView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = showView.h; sourceTree = ""; }; + E694DF311AB0CAB200D95B25 /* showView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = showView.m; sourceTree = ""; }; + E694DF321AB0CAB200D95B25 /* showView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = showView.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -72,6 +83,7 @@ 92C21CA71AAE757A0052ABE6 = { isa = PBXGroup; children = ( + E668D1EB1AAF8A0F0043A4ED /* Localizable.strings */, 92C21CB21AAE757A0052ABE6 /* iTunesSearch */, 92C21CCC1AAE757A0052ABE6 /* iTunesSearchTests */, 92C21CB11AAE757A0052ABE6 /* Products */, @@ -94,9 +106,12 @@ 92C21CE91AAE859A0052ABE6 /* Entidades */, 92C21CB71AAE757A0052ABE6 /* AppDelegate.h */, 92C21CB81AAE757A0052ABE6 /* AppDelegate.m */, + E694DF301AB0CAB200D95B25 /* showView.h */, + E694DF311AB0CAB200D95B25 /* showView.m */, + E694DF321AB0CAB200D95B25 /* showView.xib */, 92C21CBA1AAE757A0052ABE6 /* TableViewController.h */, 92C21CBB1AAE757A0052ABE6 /* TableViewController.m */, - 92C21CDC1AAE75DC0052ABE6 /* TableView.xib */, + E668D1E41AAF85690043A4ED /* TableView.xib */, 92C21CD91AAE75B30052ABE6 /* iTunesManager.h */, 92C21CDA1AAE75B30052ABE6 /* iTunesManager.m */, 92C21CC01AAE757A0052ABE6 /* Images.xcassets */, @@ -144,8 +159,8 @@ 92C21CE91AAE859A0052ABE6 /* Entidades */ = { isa = PBXGroup; children = ( - 92C21CE61AAE858E0052ABE6 /* Filme.h */, - 92C21CE71AAE858E0052ABE6 /* Filme.m */, + 92C21CE61AAE858E0052ABE6 /* Midia.h */, + 92C21CE71AAE858E0052ABE6 /* Midia.m */, ); name = Entidades; sourceTree = ""; @@ -213,6 +228,8 @@ knownRegions = ( en, Base, + pt, + fr, ); mainGroup = 92C21CA71AAE757A0052ABE6; productRefGroup = 92C21CB11AAE757A0052ABE6 /* Products */; @@ -231,8 +248,10 @@ buildActionMask = 2147483647; files = ( 92C21CC11AAE757A0052ABE6 /* Images.xcassets in Resources */, + E694DF341AB0CAB200D95B25 /* showView.xib in Resources */, 92C21CE21AAE76930052ABE6 /* TableViewCell.xib in Resources */, - 92C21CDD1AAE75DC0052ABE6 /* TableView.xib in Resources */, + E668D1E91AAF8A0F0043A4ED /* Localizable.strings in Resources */, + E668D1E21AAF85690043A4ED /* TableView.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -253,9 +272,10 @@ 92C21CBC1AAE757A0052ABE6 /* TableViewController.m in Sources */, 92C21CDB1AAE75B30052ABE6 /* iTunesManager.m in Sources */, 92C21CB91AAE757A0052ABE6 /* AppDelegate.m in Sources */, - 92C21CE81AAE858E0052ABE6 /* Filme.m in Sources */, + 92C21CE81AAE858E0052ABE6 /* Midia.m in Sources */, 92C21CE11AAE76930052ABE6 /* TableViewCell.m in Sources */, 92C21CB61AAE757A0052ABE6 /* main.m in Sources */, + E694DF331AB0CAB200D95B25 /* showView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -277,6 +297,29 @@ }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + E668D1E41AAF85690043A4ED /* TableView.xib */ = { + isa = PBXVariantGroup; + children = ( + E668D1E31AAF85690043A4ED /* Base */, + E668D1E51AAF85890043A4ED /* pt */, + E668D1E61AAF87150043A4ED /* fr */, + ); + name = TableView.xib; + sourceTree = ""; + }; + E668D1EB1AAF8A0F0043A4ED /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + E668D1EC1AAF8A120043A4ED /* en */, + E668D1ED1AAF8A170043A4ED /* pt */, + E668D1EE1AAF8A180043A4ED /* fr */, + ); + name = Localizable.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 92C21CD11AAE757A0052ABE6 /* Debug */ = { isa = XCBuildConfiguration; @@ -312,7 +355,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -348,7 +391,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/iTunesSearch/AppDelegate.m b/iTunesSearch/AppDelegate.m index d513fd8..5d40048 100644 --- a/iTunesSearch/AppDelegate.m +++ b/iTunesSearch/AppDelegate.m @@ -25,10 +25,17 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // Override point for customization after application launch. 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] init]; - [self.window setRootViewController:tvc]; + + UINavigationController *tableViewNavigationController = [[UINavigationController alloc] initWithRootViewController:tvc]; + + [tableViewNavigationController setTitle:@"MeuApp"]; + + [self.window setRootViewController:tableViewNavigationController]; [self.window makeKeyAndVisible]; return YES; } diff --git a/iTunesSearch/Base.lproj/TableView.xib b/iTunesSearch/Base.lproj/TableView.xib new file mode 100644 index 0000000..74e225a --- /dev/null +++ b/iTunesSearch/Base.lproj/TableView.xib @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iTunesSearch/Entidades/Filme.h b/iTunesSearch/Entidades/Midia.h similarity index 65% rename from iTunesSearch/Entidades/Filme.h rename to iTunesSearch/Entidades/Midia.h index eb126dc..02a071b 100644 --- a/iTunesSearch/Entidades/Filme.h +++ b/iTunesSearch/Entidades/Midia.h @@ -8,13 +8,16 @@ #import -@interface Filme : NSObject +@interface Midia : NSObject @property (nonatomic, strong) NSString *nome; @property (nonatomic, strong) NSString *trackId; @property (nonatomic, strong) NSString *artista; -@property (nonatomic, strong) NSString *duracao; +@property (nonatomic, strong) NSNumber *duracao; @property (nonatomic, strong) NSString *genero; +@property (nonatomic, strong) NSNumber *preco; @property (nonatomic, strong) NSString *pais; +@property (nonatomic, strong) NSString *artWork; +@property (nonatomic, strong) NSString *tipo; @end diff --git a/iTunesSearch/Entidades/Filme.m b/iTunesSearch/Entidades/Midia.m similarity index 77% rename from iTunesSearch/Entidades/Filme.m rename to iTunesSearch/Entidades/Midia.m index f00d84e..1f6cc52 100644 --- a/iTunesSearch/Entidades/Filme.m +++ b/iTunesSearch/Entidades/Midia.m @@ -6,8 +6,8 @@ // Copyright (c) 2015 joaquim. All rights reserved. // -#import "Filme.h" +#import "Midia.h" -@implementation Filme +@implementation Midia @end diff --git a/iTunesSearch/Images.xcassets/Ifilme.imageset/Contents.json b/iTunesSearch/Images.xcassets/Ifilme.imageset/Contents.json new file mode 100644 index 0000000..3ed3bc8 --- /dev/null +++ b/iTunesSearch/Images.xcassets/Ifilme.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Ifilme.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iTunesSearch/Images.xcassets/Ifilme.imageset/Ifilme.png b/iTunesSearch/Images.xcassets/Ifilme.imageset/Ifilme.png new file mode 100644 index 0000000..9719b69 Binary files /dev/null and b/iTunesSearch/Images.xcassets/Ifilme.imageset/Ifilme.png differ diff --git a/iTunesSearch/Images.xcassets/Imusic.imageset/Contents.json b/iTunesSearch/Images.xcassets/Imusic.imageset/Contents.json new file mode 100644 index 0000000..22a0e9d --- /dev/null +++ b/iTunesSearch/Images.xcassets/Imusic.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "Imusic.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iTunesSearch/Images.xcassets/Imusic.imageset/Imusic.png b/iTunesSearch/Images.xcassets/Imusic.imageset/Imusic.png new file mode 100644 index 0000000..0c3ac22 Binary files /dev/null and b/iTunesSearch/Images.xcassets/Imusic.imageset/Imusic.png differ diff --git a/iTunesSearch/SearchBar.h b/iTunesSearch/SearchBar.h new file mode 100644 index 0000000..b9f6bef --- /dev/null +++ b/iTunesSearch/SearchBar.h @@ -0,0 +1,13 @@ +// +// SearchBar.h +// iTunesSearch +// +// Created by João Vitor dos Santos Schimmelpfeng on 10/03/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import + +@interface SearchBar : UISearchBar + +@end diff --git a/iTunesSearch/SearchBar.m b/iTunesSearch/SearchBar.m new file mode 100644 index 0000000..c779321 --- /dev/null +++ b/iTunesSearch/SearchBar.m @@ -0,0 +1,16 @@ +// +// SearchBar.m +// iTunesSearch +// +// Created by João Vitor dos Santos Schimmelpfeng on 10/03/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "SearchBar.h" + +@implementation SearchBar +- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar +{ + +} +@end diff --git a/iTunesSearch/SearchView.h b/iTunesSearch/SearchView.h new file mode 100644 index 0000000..8206aca --- /dev/null +++ b/iTunesSearch/SearchView.h @@ -0,0 +1,13 @@ +// +// SearchViewController.h +// iTunesSearch +// +// Created by João Vitor dos Santos Schimmelpfeng on 10/03/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import + +@interface SearchView : UIView + +@end diff --git a/iTunesSearch/SearchView.m b/iTunesSearch/SearchView.m new file mode 100644 index 0000000..2ef930c --- /dev/null +++ b/iTunesSearch/SearchView.m @@ -0,0 +1,19 @@ +// +// SearchViewController.m +// iTunesSearch +// +// Created by João Vitor dos Santos Schimmelpfeng on 10/03/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "SearchView.h" + +@interface SearchView () + +@end + +@implementation SearchView + + + +@end diff --git a/iTunesSearch/SearchView.xib b/iTunesSearch/SearchView.xib new file mode 100644 index 0000000..a2d900d --- /dev/null +++ b/iTunesSearch/SearchView.xib @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..5b9d1d7 100644 --- a/iTunesSearch/TableViewCell.h +++ b/iTunesSearch/TableViewCell.h @@ -12,6 +12,10 @@ @property (weak, nonatomic) IBOutlet UILabel *nome; @property (weak, nonatomic) IBOutlet UILabel *tipo; +@property (weak, nonatomic) IBOutlet UIImageView *imgView; +@property (weak, nonatomic) IBOutlet UIImageView *imageIcon; +@property (weak, nonatomic) IBOutlet UILabel *preco; - +-(void) setViewTumb:(NSString *)url; +-(void) setImgIcon:(NSString *)tipo; @end diff --git a/iTunesSearch/TableViewCell.m b/iTunesSearch/TableViewCell.m index ffac89c..314677b 100644 --- a/iTunesSearch/TableViewCell.m +++ b/iTunesSearch/TableViewCell.m @@ -2,13 +2,14 @@ // TableViewCell.m // iTunesSearch // -// Created by joaquim on 09/03/15. -// Copyright (c) 2015 joaquim. All rights reserved. +// Created by Joao Schimmelpfeng +// Copyright (c) 2015 Joao. All rights reserved. // #import "TableViewCell.h" @implementation TableViewCell +@synthesize imgView,imageIcon; - (void)awakeFromNib { // Initialization code @@ -20,4 +21,28 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated { // Configure the view for the selected state } + +-(void) setViewTumb:(NSString *)url +{ + NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: url]]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + + imgView.image = image; +} + + +-(void) setImgIcon:(NSString *)tipo +{ + if([tipo isEqualToString:@"movie"]) + { + UIImage *img = [UIImage imageNamed:@"Ifilme"]; + imageIcon.image = img; + } + else if([tipo isEqualToString:@"song"]) + { + UIImage *img = [UIImage imageNamed:@"Imusic"]; + imageIcon.image = img; + } +} + @end diff --git a/iTunesSearch/TableViewCell.xib b/iTunesSearch/TableViewCell.xib index bf8bd3f..3cf75d9 100644 --- a/iTunesSearch/TableViewCell.xib +++ b/iTunesSearch/TableViewCell.xib @@ -1,5 +1,5 @@ - + @@ -7,40 +7,132 @@ - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + diff --git a/iTunesSearch/TableViewController.h b/iTunesSearch/TableViewController.h index 0cbb5c4..ba8c477 100644 --- a/iTunesSearch/TableViewController.h +++ b/iTunesSearch/TableViewController.h @@ -8,10 +8,12 @@ #import -@interface TableViewController : UIViewController +@interface TableViewController : UIViewController @property (strong, nonatomic) IBOutlet UITableView *tableview; +- (IBAction)clicked:(id)sender; +@property (weak, nonatomic) IBOutlet UISearchBar *searchBar1; @end diff --git a/iTunesSearch/TableViewController.m b/iTunesSearch/TableViewController.m index f689980..7e5da3a 100644 --- a/iTunesSearch/TableViewController.m +++ b/iTunesSearch/TableViewController.m @@ -9,60 +9,104 @@ #import "TableViewController.h" #import "TableViewCell.h" #import "iTunesManager.h" -#import "Entidades/Filme.h" +#import "Entidades/Midia.h" +#import "SearchView.h" +#import "showView.h" @interface TableViewController () { NSArray *midias; + } @end @implementation TableViewController +@synthesize searchBar1; +iTunesManager *itunes; - -- (void)viewDidLoad { +- (void)viewDidLoad +{ [super viewDidLoad]; UINib *nib = [UINib nibWithNibName:@"TableViewCell" bundle:nil]; [self.tableview registerNib:nib forCellReuseIdentifier:@"celulaPadrao"]; - iTunesManager *itunes = [iTunesManager sharedInstance]; - midias = [itunes buscarMidias:@"Apple"]; + [searchBar1 setDelegate:self]; + NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; + NSString *lastSearch = [def objectForKey:@"search"]; + if(lastSearch != NULL) + { + searchBar1.text = lastSearch; + } -#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)]; + itunes = [iTunesManager sharedInstance]; } -- (void)didReceiveMemoryWarning { +- (void)didReceiveMemoryWarning +{ [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. } #pragma mark - Metodos do UITableViewDataSource --(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return [midias count]; } --(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return [midias count]; +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return [[midias objectAtIndex:section] count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { TableViewCell *celula = [self.tableview dequeueReusableCellWithIdentifier:@"celulaPadrao"]; - Filme *filme = [midias objectAtIndex:indexPath.row]; + Midia *filme; + filme = [[midias objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; [celula.nome setText:filme.nome]; - [celula.tipo setText:@"Filme"]; + [celula.preco setText:[filme.preco stringValue]]; + [celula.tipo setText:NSLocalizedString(filme.tipo, nil)]; + [celula setViewTumb:filme.artWork]; + [celula setImgIcon:filme.tipo]; return celula; } --(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + NSString *sectionName; + Midia *f = [[midias objectAtIndex:section] objectAtIndex:0]; + sectionName = NSLocalizedString(f.tipo, nil); + + return sectionName; +} + +- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar +{ + midias = [itunes buscarMidias:searchBar.text]; + [self.tableview reloadData]; +} + +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ return 70; } +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + showView *sview = [showView instance]; + Midia *f = [[midias objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; + sview.media = f; + [self.navigationController pushViewController:sview animated:YES]; + + +} +- (IBAction)clicked:(id)sender +{ + [self searchBarSearchButtonClicked:searchBar1]; +} @end diff --git a/iTunesSearch/fr.lproj/TableView.strings b/iTunesSearch/fr.lproj/TableView.strings new file mode 100644 index 0000000..13a2a74 --- /dev/null +++ b/iTunesSearch/fr.lproj/TableView.strings @@ -0,0 +1,3 @@ + +/* Class = "IBUIButton"; normalTitle = "Search"; ObjectID = "yeY-bN-ttI"; */ +"yeY-bN-ttI.normalTitle" = "Recherche"; diff --git a/iTunesSearch/iTunesManager.m b/iTunesSearch/iTunesManager.m index e2babda..295bb5f 100644 --- a/iTunesSearch/iTunesManager.m +++ b/iTunesSearch/iTunesManager.m @@ -7,7 +7,7 @@ // #import "iTunesManager.h" -#import "Entidades/Filme.h" +#import "Entidades/Midia.h" @implementation iTunesManager @@ -30,11 +30,50 @@ + (id)sharedInstance - (NSArray *)buscarMidias:(NSString *)termo { - if (!termo) { + NSString *mediaTo = @"all"; + + if (!termo) + { termo = @""; } + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [defaults setObject:termo forKey:@"search"]; + [defaults synchronize]; + + termo = [termo stringByReplacingOccurrencesOfString:@" " withString:@"_"]; + + NSString *expressao = @"(-music-)|(-movie-)"; + NSRegularExpression *ex1 = [NSRegularExpression regularExpressionWithPattern:expressao options:0 error:NULL]; + + + NSRange range1 = NSMakeRange(0, [termo length]); + + NSTextCheckingResult *match1 = [ex1 firstMatchInString:termo options:0 range:range1]; + + + + NSString *result = [termo substringWithRange:[match1 rangeAtIndex:0]]; + + + NSLog(@"%@",result); + + if(match1 != nil) + { + if([result isEqualToString:@"-music-"]) + { + mediaTo = @"music"; + } + else if([result isEqualToString:@"-movie-"]) + { + mediaTo = @"movie"; + } + + + } + - NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&media=movie", termo]; + + NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&media=%@", termo,mediaTo]; NSData *jsonData = [NSData dataWithContentsOfURL: [NSURL URLWithString:url]]; NSError *error; @@ -47,20 +86,46 @@ - (NSArray *)buscarMidias:(NSString *)termo { } NSArray *resultados = [resultado objectForKey:@"results"]; + + NSMutableArray *final = [[NSMutableArray alloc]init]; NSMutableArray *filmes = [[NSMutableArray alloc] init]; + NSMutableArray *musicas = [[NSMutableArray alloc] init]; for (NSDictionary *item in resultados) { - Filme *filme = [[Filme alloc] init]; + Midia *filme = [[Midia 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 setArtWork:[item objectForKey:@"artworkUrl100"]]; + [filme setPreco:[item objectForKey:@"trackPrice"]]; [filme setPais:[item objectForKey:@"country"]]; - [filmes addObject:filme]; + [filme setTipo:[item objectForKey:@"kind"]]; + + + + + if([filme.tipo isEqualToString:@"feature-movie"]) + { + [filme setTipo:@"movie"]; + [filmes addObject:filme]; + } + else if([filme.tipo isEqualToString:@"song"]) + { + [musicas addObject:filme]; + } } - return filmes; + if([filmes count] != 0) + { + [final addObject:filmes]; + } + if([musicas count] != 0) + { + [final addObject:musicas]; + } + return final; } diff --git a/iTunesSearch/pt.lproj/TableView.strings b/iTunesSearch/pt.lproj/TableView.strings new file mode 100644 index 0000000..e4877f1 --- /dev/null +++ b/iTunesSearch/pt.lproj/TableView.strings @@ -0,0 +1,3 @@ + +/* Class = "IBUIButton"; normalTitle = "Buscar"; ObjectID = "yeY-bN-ttI"; */ +"yeY-bN-ttI.normalTitle" = "Buscar"; diff --git a/iTunesSearch/showView.h b/iTunesSearch/showView.h new file mode 100644 index 0000000..08f972d --- /dev/null +++ b/iTunesSearch/showView.h @@ -0,0 +1,21 @@ +// +// showView.h +// iTunesSearch +// +// Created by João Vitor dos Santos Schimmelpfeng on 11/03/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Midia.h" + +@interface showView : UIViewController +@property (weak, nonatomic) IBOutlet UIImageView *imageView; +@property (weak, nonatomic) IBOutlet UILabel *titulo; +@property (weak, nonatomic) IBOutlet UILabel *artista; +@property (weak, nonatomic) IBOutlet UILabel *preco; +@property (weak, nonatomic) IBOutlet UILabel *genero; +@property Midia *media; ++(showView *)instance; + +@end diff --git a/iTunesSearch/showView.m b/iTunesSearch/showView.m new file mode 100644 index 0000000..3ab4fc9 --- /dev/null +++ b/iTunesSearch/showView.m @@ -0,0 +1,57 @@ +// +// showView.m +// iTunesSearch +// +// Created by João Vitor dos Santos Schimmelpfeng on 11/03/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "showView.h" +#import "Midia.h" + +@interface showView () + +@end + +@implementation showView +@synthesize media,imageView,titulo,artista,preco,genero; +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. +} + +-(void) viewWillAppear:(BOOL)animated +{ + artista.text = media.artista; + titulo.text = media.nome; + preco.text = [media.preco stringValue]; + genero.text = media.genero; + NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: media.artWork]]; + UIImage *image = [[UIImage alloc] initWithData:imageData]; + imageView.image = image; +} +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + ++ (showView *)instance +{ + static showView *sharedContador = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^ + { + sharedContador = [[self alloc] init]; + }); + return sharedContador; +} +/* +#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/showView.xib b/iTunesSearch/showView.xib new file mode 100644 index 0000000..033c85e --- /dev/null +++ b/iTunesSearch/showView.xib @@ -0,0 +1,307 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pt.lproj/Localizable.strings b/pt.lproj/Localizable.strings new file mode 100644 index 0000000..4d4d342 --- /dev/null +++ b/pt.lproj/Localizable.strings @@ -0,0 +1,9 @@ +/* + LocalizableString.strings + iTunesSearch + + Created by João Vitor dos Santos Schimmelpfeng on 10/03/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ +"movie" = "Filme"; +"song" = "Musica"; \ No newline at end of file