diff --git a/Classes/LinphoneUI/UIConfirmationDialog.h b/Classes/LinphoneUI/UIConfirmationDialog.h new file mode 100644 index 000000000..12c8f0175 --- /dev/null +++ b/Classes/LinphoneUI/UIConfirmationDialog.h @@ -0,0 +1,25 @@ +// +// UIConfirmationDialog.h +// linphone +// +// Created by Gautier Pelloux-Prayer on 11/09/15. +// +// + +typedef void (^UIConfirmationBlock)(void); + +@interface UIConfirmationDialog : UIViewController { + + UIConfirmationBlock onCancelCb; + UIConfirmationBlock onConfirmCb; +} + ++ (void)ShowWithMessage:(NSString *)message + onCancelClick:(UIConfirmationBlock)onCancel + onConfirmationClick:(UIConfirmationBlock)onConfirm; + +@property(weak, nonatomic) IBOutlet UILabel *titleLabel; +- (IBAction)onCancelClick:(id)sender; +- (IBAction)onConfirmationClick:(id)sender; + +@end diff --git a/Classes/LinphoneUI/UIConfirmationDialog.m b/Classes/LinphoneUI/UIConfirmationDialog.m new file mode 100644 index 000000000..0700b3d7e --- /dev/null +++ b/Classes/LinphoneUI/UIConfirmationDialog.m @@ -0,0 +1,44 @@ +// +// UIConfirmationDialog.m +// linphone +// +// Created by Gautier Pelloux-Prayer on 11/09/15. +// +// + +#import "UIConfirmationDialog.h" +#import "PhoneMainView.h" + +@implementation UIConfirmationDialog + ++ (void)ShowWithMessage:(NSString *)message + onCancelClick:(UIConfirmationBlock)onCancel + onConfirmationClick:(UIConfirmationBlock)onConfirm { + UIConfirmationDialog *dialog = + [[UIConfirmationDialog alloc] initWithNibName:NSStringFromClass(self.class) bundle:NSBundle.mainBundle]; + + [PhoneMainView.instance.mainViewController.view addSubview:dialog.view]; + [PhoneMainView.instance.mainViewController addChildViewController:dialog]; + + dialog->onCancelCb = onCancel; + dialog->onConfirmCb = onConfirm; + + [dialog.titleLabel setText:message]; +} + +- (IBAction)onCancelClick:(id)sender { + [self.view removeFromSuperview]; + [self removeFromParentViewController]; + if (onCancelCb) { + onCancelCb(); + } +} + +- (IBAction)onConfirmationClick:(id)sender { + [self.view removeFromSuperview]; + [self removeFromParentViewController]; + if (onConfirmCb) { + onConfirmCb(); + } +} +@end diff --git a/Classes/LinphoneUI/UIConfirmationDialog.xib b/Classes/LinphoneUI/UIConfirmationDialog.xib new file mode 100644 index 000000000..3f0fc6d10 --- /dev/null +++ b/Classes/LinphoneUI/UIConfirmationDialog.xib @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index 4a35564af..f591b24b4 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -40,6 +40,7 @@ #import "SideMenuView.h" #import "AssistantView.h" +#import "UIConfirmationDialog.h" #import "DTAlertView.h" #import "DTActionSheet.h" #import "Utils.h" diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index ebb571f42..7bd596b68 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -243,6 +243,8 @@ 636316D41A1DEC650009B839 /* SettingsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D61A1DEC650009B839 /* SettingsView.xib */; }; 636316D91A1DECC90009B839 /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D71A1DECC90009B839 /* PhoneMainView.xib */; }; 636BC9971B5F921B00C754CE /* UIIconButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 636BC9961B5F921B00C754CE /* UIIconButton.m */; }; + 63701DD61BA31DA1006A9AE3 /* UIConfirmationDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 63701DD51BA31DA1006A9AE3 /* UIConfirmationDialog.xib */; }; + 63701DDF1BA32039006A9AE3 /* UIConfirmationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 63701DDE1BA32039006A9AE3 /* UIConfirmationDialog.m */; }; 637157A11B283FE200C91677 /* FileTransferDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 637157A01B283FE200C91677 /* FileTransferDelegate.m */; }; 639CEAFD1A1DF4D9004DE38F /* StatusBarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 639CEAFF1A1DF4D9004DE38F /* StatusBarView.xib */; }; 639CEB001A1DF4E4004DE38F /* UIHistoryCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 639CEB021A1DF4E4004DE38F /* UIHistoryCell.xib */; }; @@ -845,6 +847,9 @@ 636316DB1A1DEDD80009B839 /* ru */ = {isa = PBXFileReference; fileEncoding = 2483028224; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/HistoryDetailsView.strings; sourceTree = ""; }; 636BC9951B5F921B00C754CE /* UIIconButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIIconButton.h; sourceTree = ""; }; 636BC9961B5F921B00C754CE /* UIIconButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIIconButton.m; sourceTree = ""; }; + 63701DD51BA31DA1006A9AE3 /* UIConfirmationDialog.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UIConfirmationDialog.xib; sourceTree = ""; }; + 63701DDD1BA32039006A9AE3 /* UIConfirmationDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIConfirmationDialog.h; sourceTree = ""; }; + 63701DDE1BA32039006A9AE3 /* UIConfirmationDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIConfirmationDialog.m; sourceTree = ""; }; 6371579F1B283FE200C91677 /* FileTransferDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileTransferDelegate.h; path = Utils/FileTransferDelegate.h; sourceTree = ""; }; 637157A01B283FE200C91677 /* FileTransferDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FileTransferDelegate.m; path = Utils/FileTransferDelegate.m; sourceTree = ""; }; 639CEAFE1A1DF4D9004DE38F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/StatusBarView.xib; sourceTree = ""; }; @@ -1452,6 +1457,9 @@ D32460E5159D9AAD00BA7F3A /* UITransparentView.m */, 340751E5150F38FC00B89C47 /* UIVideoButton.h */, 340751E6150F38FD00B89C47 /* UIVideoButton.m */, + 63701DD51BA31DA1006A9AE3 /* UIConfirmationDialog.xib */, + 63701DDD1BA32039006A9AE3 /* UIConfirmationDialog.h */, + 63701DDE1BA32039006A9AE3 /* UIConfirmationDialog.m */, ); path = LinphoneUI; sourceTree = ""; @@ -2416,6 +2424,7 @@ 634CEDB31B6630DB00D7A921 /* chat_message_delivered.png in Resources */, 63AADBED1B6A0FF200AA16FD /* corner-left-top.png in Resources */, 634CEE131B6630DB00D7A921 /* status_disconnected.png in Resources */, + 63701DD61BA31DA1006A9AE3 /* UIConfirmationDialog.xib in Resources */, 634CEDB71B6630DB00D7A921 /* chat_picture_over.png in Resources */, 634CEDF91B6630DB00D7A921 /* pause_small_disabled.png in Resources */, F0C1F8EB1A277ADA009402C9 /* LaunchScreen.xib in Resources */, @@ -2558,6 +2567,7 @@ 630CF5571AF7CE1500539F7A /* UITextField+DoneButton.m in Sources */, 2214EBF312F86360002A5394 /* UIMicroButton.m in Sources */, 22968A5F12F875C600588287 /* UISpeakerButton.m in Sources */, + 63701DDF1BA32039006A9AE3 /* UIConfirmationDialog.m in Sources */, 22C755601317E59C007BC101 /* UIBluetoothButton.m in Sources */, 22AA8B0113D83F6300B30535 /* UICamSwitch.m in Sources */, 636BC9971B5F921B00C754CE /* UIIconButton.m in Sources */,