diff --git a/ExampleProject/Example.xcodeproj/project.pbxproj b/ExampleProject/Example.xcodeproj/project.pbxproj index 8d868b04..52a7f2d9 100644 --- a/ExampleProject/Example.xcodeproj/project.pbxproj +++ b/ExampleProject/Example.xcodeproj/project.pbxproj @@ -8,6 +8,10 @@ /* Begin PBXBuildFile section */ 0C9D527520AF4EAA93E80BC5 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A64AE23935D5499BAF0AC8C1 /* libPods.a */; }; + 4C67F9E218F6C38700021ADD /* closeIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C67F9E018F6C38700021ADD /* closeIcon.png */; }; + 4C67F9E318F6C38700021ADD /* closeIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C67F9E118F6C38700021ADD /* closeIcon@2x.png */; }; + 4CCFEF4318EF06FF00CDFE92 /* TSMessageCustomItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCFEF4218EF06FF00CDFE92 /* TSMessageCustomItem.m */; }; + 4CCFEF4618EF09C100CDFE92 /* TSMessageCustomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCFEF4518EF09C100CDFE92 /* TSMessageCustomView.m */; }; CA0B97051719CD6800E06F84 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA0B97041719CD6800E06F84 /* UIKit.framework */; }; CA0B97071719CD6800E06F84 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA0B97061719CD6800E06F84 /* Foundation.framework */; }; CA0B97091719CD6800E06F84 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA0B97081719CD6800E06F84 /* CoreGraphics.framework */; }; @@ -23,6 +27,12 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 4C67F9E018F6C38700021ADD /* closeIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = closeIcon.png; sourceTree = ""; }; + 4C67F9E118F6C38700021ADD /* closeIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "closeIcon@2x.png"; sourceTree = ""; }; + 4CCFEF4118EF06FF00CDFE92 /* TSMessageCustomItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSMessageCustomItem.h; sourceTree = ""; }; + 4CCFEF4218EF06FF00CDFE92 /* TSMessageCustomItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSMessageCustomItem.m; sourceTree = ""; }; + 4CCFEF4418EF09C100CDFE92 /* TSMessageCustomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSMessageCustomView.h; sourceTree = ""; }; + 4CCFEF4518EF09C100CDFE92 /* TSMessageCustomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TSMessageCustomView.m; sourceTree = ""; }; 8B33F75B47A447C8B36A0061 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = SOURCE_ROOT; }; A64AE23935D5499BAF0AC8C1 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; CA0B97011719CD6800E06F84 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -98,6 +108,10 @@ CA0B97261719CD6800E06F84 /* TSDemoViewController.h */, CA0B97271719CD6800E06F84 /* TSDemoViewController.m */, CA0B970B1719CD6800E06F84 /* Supporting Files */, + 4CCFEF4118EF06FF00CDFE92 /* TSMessageCustomItem.h */, + 4CCFEF4218EF06FF00CDFE92 /* TSMessageCustomItem.m */, + 4CCFEF4418EF09C100CDFE92 /* TSMessageCustomView.h */, + 4CCFEF4518EF09C100CDFE92 /* TSMessageCustomView.m */, ); path = Example; sourceTree = ""; @@ -105,6 +119,8 @@ CA0B970B1719CD6800E06F84 /* Supporting Files */ = { isa = PBXGroup; children = ( + 4C67F9E018F6C38700021ADD /* closeIcon.png */, + 4C67F9E118F6C38700021ADD /* closeIcon@2x.png */, CA0B970C1719CD6800E06F84 /* Example-Info.plist */, CA0B970D1719CD6800E06F84 /* InfoPlist.strings */, CA0B97101719CD6800E06F84 /* main.m */, @@ -170,8 +186,10 @@ buildActionMask = 2147483647; files = ( CA0B970F1719CD6800E06F84 /* InfoPlist.strings in Resources */, + 4C67F9E318F6C38700021ADD /* closeIcon@2x.png in Resources */, CA0B97171719CD6800E06F84 /* Default.png in Resources */, CA0B97191719CD6800E06F84 /* Default@2x.png in Resources */, + 4C67F9E218F6C38700021ADD /* closeIcon.png in Resources */, CA0B971B1719CD6800E06F84 /* Default-568h@2x.png in Resources */, CA0B971E1719CD6800E06F84 /* MainStoryboard.storyboard in Resources */, CAA3C9E817C3CD180085E06E /* AlternativeDesign.json in Resources */, @@ -204,6 +222,8 @@ files = ( CA0B97111719CD6800E06F84 /* main.m in Sources */, CA0B97151719CD6800E06F84 /* TSAppDelegate.m in Sources */, + 4CCFEF4618EF09C100CDFE92 /* TSMessageCustomView.m in Sources */, + 4CCFEF4318EF06FF00CDFE92 /* TSMessageCustomItem.m in Sources */, CA0B97281719CD6800E06F84 /* TSDemoViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ExampleProject/Example.xcworkspace/xcshareddata/Example.xccheckout b/ExampleProject/Example.xcworkspace/xcshareddata/Example.xccheckout index c8327a4b..5ec51d74 100644 --- a/ExampleProject/Example.xcworkspace/xcshareddata/Example.xccheckout +++ b/ExampleProject/Example.xcworkspace/xcshareddata/Example.xccheckout @@ -5,34 +5,34 @@ IDESourceControlProjectFavoriteDictionaryKey IDESourceControlProjectIdentifier - 78E13C39-DCE2-42E8-B56F-F65483531CDC + DAF402E2-1D5F-4FCC-BC4E-54E674A41828 IDESourceControlProjectName Example IDESourceControlProjectOriginsDictionary - A82D8531-0480-4292-B9CA-F43F680C1C78 - https://github.com/mRs-/TSMessages.git + 2462041E-2250-43D4-B8B0-7C9802F94EB6 + https://github.com/XBeg9/TSMessages.git IDESourceControlProjectPath ExampleProject/Example.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - A82D8531-0480-4292-B9CA-F43F680C1C78 + 2462041E-2250-43D4-B8B0-7C9802F94EB6 ../.. IDESourceControlProjectURL - https://github.com/mRs-/TSMessages.git + https://github.com/XBeg9/TSMessages.git IDESourceControlProjectVersion 110 IDESourceControlProjectWCCIdentifier - A82D8531-0480-4292-B9CA-F43F680C1C78 + 2462041E-2250-43D4-B8B0-7C9802F94EB6 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - A82D8531-0480-4292-B9CA-F43F680C1C78 + 2462041E-2250-43D4-B8B0-7C9802F94EB6 IDESourceControlWCCName TSMessages diff --git a/ExampleProject/Example/TSDemoViewController.h b/ExampleProject/Example/TSDemoViewController.h index b4a4cdd5..5f4e33fb 100644 --- a/ExampleProject/Example/TSDemoViewController.h +++ b/ExampleProject/Example/TSDemoViewController.h @@ -9,8 +9,7 @@ #import #import "TSMessageView.h" -@interface TSDemoViewController : UIViewController - +@interface TSDemoViewController : UIViewController - (IBAction)didTapError:(id)sender; - (IBAction)didTapWarning:(id)sender; @@ -24,5 +23,6 @@ - (IBAction)didTapText:(id)sender; - (IBAction)didTapCustomDesign:(id)sender; - (IBAction)didTapNavbarHidden:(id)sender; +- (IBAction)didTapCustomView:(id)sender; @end diff --git a/ExampleProject/Example/TSDemoViewController.m b/ExampleProject/Example/TSDemoViewController.m index fd057035..b89ac65a 100644 --- a/ExampleProject/Example/TSDemoViewController.m +++ b/ExampleProject/Example/TSDemoViewController.m @@ -10,6 +10,7 @@ #import "TSDemoViewController.h" #import "TSMessage.h" #import "TSMessageView.h" +#import "TSMessageCustomItem.h" @implementation TSDemoViewController @@ -162,9 +163,16 @@ - (IBAction)didTapCustomDesign:(id)sender } - - - +- (IBAction)didTapCustomView:(id)sender { + TSMessageCustomItem *item = [TSMessageCustomItem itemWithTitle:@"Test" subtitle:@"description" type:TSMessageNotificationTypeSuccess inViewController:self tapHandler:^(TSMessageCustomItem *item) { + NSLog(@"Message did pressed"); + } iconHandler:^(TSMessageCustomItem *item) { + NSLog(@"Icon did pressed"); + } disclosureView:nil disclosureHandler:^(TSMessageCustomItem *item) { + NSLog(@"Disclosure view did pressed"); + }]; + [TSMessage showNotificationMessageWithItem:item]; +} - (CGFloat)navigationbarBottomOfViewController:(UIViewController *)viewController { @@ -174,4 +182,5 @@ - (CGFloat)navigationbarBottomOfViewController:(UIViewController *)viewControlle - (IBAction)didTapNavbarHidden:(id)sender { self.navigationController.navigationBarHidden = !self.navigationController.navigationBarHidden; } + @end diff --git a/ExampleProject/Example/TSMessageCustomItem.h b/ExampleProject/Example/TSMessageCustomItem.h new file mode 100644 index 00000000..676303b3 --- /dev/null +++ b/ExampleProject/Example/TSMessageCustomItem.h @@ -0,0 +1,25 @@ +// +// TSMessageCustomItem.h +// Example +// +// Created by Fedya Skitsko on 4/4/14. +// Copyright (c) 2014 Toursprung. All rights reserved. +// + +#import "TSMessageItem.h" + +@interface TSMessageCustomItem : TSMessageItem + +@property (copy, readwrite, nonatomic) void (^disclosureSelectionHandler)(id item); +@property (copy, readwrite, nonatomic) UIView *disclosureView; + ++ (instancetype)itemWithTitle:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)notificationType + inViewController:(UIViewController *)viewController + tapHandler:(void(^)(TSMessageCustomItem *item))tapHandler + iconHandler:(void(^)(TSMessageCustomItem *item))iconHandler + disclosureView:(UIView *)disclosureView + disclosureHandler:(void(^)(TSMessageCustomItem *item))disclosureHandler; + +@end diff --git a/ExampleProject/Example/TSMessageCustomItem.m b/ExampleProject/Example/TSMessageCustomItem.m new file mode 100644 index 00000000..feb6d969 --- /dev/null +++ b/ExampleProject/Example/TSMessageCustomItem.m @@ -0,0 +1,34 @@ +// +// TSMessageCustomItem.m +// Example +// +// Created by Fedya Skitsko on 4/4/14. +// Copyright (c) 2014 Toursprung. All rights reserved. +// + +#import "TSMessageCustomItem.h" +#import "TSMessageCustomView.h" + +@implementation TSMessageCustomItem + ++ (instancetype)itemWithTitle:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)notificationType + inViewController:(UIViewController *)viewController + tapHandler:(void(^)(TSMessageCustomItem *item))tapHandler + iconHandler:(void(^)(TSMessageCustomItem *item))iconHandler + disclosureView:(UIView *)disclosureView + disclosureHandler:(void(^)(TSMessageCustomItem *item))disclosureHandler { + + TSMessageCustomItem *item = [[TSMessageCustomItem alloc] initWithTitle:title subtitle:subtitle image:[UIImage imageNamed:@"closeIcon"] type:notificationType duration:3.0 inViewController:viewController atPosition:TSMessageNotificationPositionBottom canBeDismissedByUser:YES tapHandler:tapHandler iconHandler:iconHandler]; + item.disclosureView = disclosureView; + item.disclosureSelectionHandler = disclosureHandler; + + return item; +} + +- (Class)classForView { + return [TSMessageCustomView class]; +} + +@end diff --git a/ExampleProject/Example/TSMessageCustomView.h b/ExampleProject/Example/TSMessageCustomView.h new file mode 100644 index 00000000..dbeb581b --- /dev/null +++ b/ExampleProject/Example/TSMessageCustomView.h @@ -0,0 +1,16 @@ +// +// TSMessageCustomView.h +// Example +// +// Created by Fedya Skitsko on 4/4/14. +// Copyright (c) 2014 Toursprung. All rights reserved. +// + +#import "TSMessageView.h" +#import "TSMessageCustomItem.h" + +@interface TSMessageCustomView : TSMessageView + +@property (nonatomic, strong) TSMessageCustomItem *item; + +@end \ No newline at end of file diff --git a/ExampleProject/Example/TSMessageCustomView.m b/ExampleProject/Example/TSMessageCustomView.m new file mode 100644 index 00000000..30e22ff3 --- /dev/null +++ b/ExampleProject/Example/TSMessageCustomView.m @@ -0,0 +1,76 @@ +// +// TSMessageCustomView.m +// Example +// +// Created by Fedya Skitsko on 4/4/14. +// Copyright (c) 2014 Toursprung. All rights reserved. +// + +#import "TSMessageCustomView.h" + +@interface TSMessageCustomView() + +@property (nonatomic) UIButton *closeButton; + +@end + +@implementation TSMessageCustomView + +#pragma mark - Setters / Getters + +- (UIButton *)closeButton { + if (!_closeButton) { + _closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_closeButton setImage:[UIImage imageNamed:@"closeIcon"] forState:UIControlStateNormal]; + _closeButton.frame = CGRectMake(0, 0, 20, 20); + [_closeButton addTarget:self action:@selector(closeButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + } + return _closeButton; +} + +#pragma mark - Initialization + +- (id)initWithItem:(TSMessageItem *)item +{ + if (self = [super initWithItem:item]) + { + [self setup]; + } + return self; +} + ++ (CGFloat)heightWithItem:(TSMessageCustomItem *)item { + CGFloat calculatedHeight = [super heightWithItem:item]; + + return calculatedHeight; +} + +#pragma mark - Lifecycle + +- (void)setup { + [super setup]; + + [self.iconImageView removeFromSuperview]; + + self.textSpaceLeft = 17.5f; + [self addSubview:self.closeButton]; + self.alpha = 0.9f; +} + +-(void)layoutSubviews { + [super layoutSubviews]; + + _closeButton.frame = CGRectMake(CGRectGetWidth(self.frame) - self.textSpaceLeft - CGRectGetWidth(_closeButton.frame), roundf((CGRectGetHeight(self.frame) - CGRectGetHeight(_closeButton.frame))/2), _closeButton.frame.size.width, _closeButton.frame.size.height); +} + +#pragma mark - Actions + +- (void)closeButtonPressed { + NSLog(@"closeButtonPressed"); + + if (self.item.disclosureSelectionHandler) { + self.item.disclosureSelectionHandler(self.item); + } +} + +@end diff --git a/ExampleProject/Example/closeIcon.png b/ExampleProject/Example/closeIcon.png new file mode 100644 index 00000000..42c0b4e6 Binary files /dev/null and b/ExampleProject/Example/closeIcon.png differ diff --git a/ExampleProject/Example/closeIcon@2x.png b/ExampleProject/Example/closeIcon@2x.png new file mode 100644 index 00000000..aa0533d1 Binary files /dev/null and b/ExampleProject/Example/closeIcon@2x.png differ diff --git a/ExampleProject/Example/en.lproj/MainStoryboard.storyboard b/ExampleProject/Example/en.lproj/MainStoryboard.storyboard index 75c1c236..0b1355df 100644 --- a/ExampleProject/Example/en.lproj/MainStoryboard.storyboard +++ b/ExampleProject/Example/en.lproj/MainStoryboard.storyboard @@ -1,8 +1,8 @@ - + - + @@ -98,6 +98,15 @@ +