Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: ios/clean/chrome/browser/ui/dialogs/dialog_mediator.mm

Issue 2929563002: [iOS Clean] Added dialogs UI support.
Patch Set: Added DialogMediator Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/clean/chrome/browser/ui/dialogs/dialog_mediator.mm
diff --git a/ios/clean/chrome/browser/ui/dialogs/dialog_mediator.mm b/ios/clean/chrome/browser/ui/dialogs/dialog_mediator.mm
new file mode 100644
index 0000000000000000000000000000000000000000..6ad3e17619273dc1b0dfa9306f542ac9f4aa203b
--- /dev/null
+++ b/ios/clean/chrome/browser/ui/dialogs/dialog_mediator.mm
@@ -0,0 +1,86 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/clean/chrome/browser/ui/dialogs/dialog_mediator.h"
+
+#include "base/logging.h"
+#import "ios/clean/chrome/browser/ui/commands/dialog_commands.h"
+#import "ios/clean/chrome/browser/ui/dialogs/dialog_button_item.h"
+#import "ios/clean/chrome/browser/ui/dialogs/dialog_consumer.h"
+#import "ios/clean/chrome/browser/ui/dialogs/dialog_mediator+internal.h"
+#import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@interface DialogMediator ()
+
+// Redefine as readwrite.
+@property(nonatomic, readonly, strong) CommandDispatcher* dispatcher;
+
+@end
+
+@implementation DialogMediator
+
+@synthesize dispatcher = _dispatcher;
+
+- (instancetype)initWithDispatcher:(CommandDispatcher*)dispatcher {
+ DCHECK(dispatcher);
+ if ((self = [super init])) {
+ _dispatcher = dispatcher;
+ }
+ return self;
+}
+
+#pragma mark - Public
+
+- (void)updateConsumer:(id<DialogConsumer>)consumer {
+ [consumer setDialogTitle:[self dialogTitle]];
marq (ping after 24h) 2017/06/14 10:52:15 Usually the mediator is created or handed a pointe
kkhorimoto 2017/06/23 06:24:18 I was going to do that, but ran into style guide v
+ [consumer setDialogMessage:[self dialogMessage]];
+ [consumer setDialogButtonItems:[self buttonItems]];
+ [consumer setDialogTextFieldItems:[self textFieldItems]];
+}
+
+- (void)dialogWillStart {
+ [self.dispatcher startDispatchingToTarget:self
marq (ping after 24h) 2017/06/14 10:52:15 Starting/stopping dispatch based on coordinator st
kkhorimoto 2017/06/23 06:24:18 Done.
+ forProtocol:@protocol(DialogDismissalCommands)];
+}
+
+- (void)dialogWillStop {
+ [self.dispatcher stopDispatchingToTarget:self];
+}
+
+@end
+
+@implementation DialogMediator (Internal)
+
+- (NSString*)dialogTitle {
+ // Implemented by subclasses.
+ return nil;
+}
+
+- (NSString*)dialogMessage {
+ // Implemented by subclasses.
+ return nil;
+}
+
+- (NSArray<DialogButtonItem*>*)buttonItems {
+ // Implemented by subclasses.
+ return nil;
+}
+
+- (NSArray<DialogTextFieldItem*>*)textFieldItems {
+ // Implemented by subclasses.
+ return nil;
+}
+
+#pragma mark - DialogDismissalCommands
+
+- (void)dismissDialogWithButtonTag:(id)buttonTag
+ userInputStrings:(NSArray<NSString*>*)inputStrings {
+ // Implemented by subclasses.
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698