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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ios/clean/chrome/browser/ui/dialogs/dialog_mediator.h"
6
7 #include "base/logging.h"
8 #import "ios/clean/chrome/browser/ui/commands/dialog_commands.h"
9 #import "ios/clean/chrome/browser/ui/dialogs/dialog_button_item.h"
10 #import "ios/clean/chrome/browser/ui/dialogs/dialog_consumer.h"
11 #import "ios/clean/chrome/browser/ui/dialogs/dialog_mediator+internal.h"
12 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h"
13
14 #if !defined(__has_feature) || !__has_feature(objc_arc)
15 #error "This file requires ARC support."
16 #endif
17
18 @interface DialogMediator ()
19
20 // Redefine as readwrite.
21 @property(nonatomic, readonly, strong) CommandDispatcher* dispatcher;
22
23 @end
24
25 @implementation DialogMediator
26
27 @synthesize dispatcher = _dispatcher;
28
29 - (instancetype)initWithDispatcher:(CommandDispatcher*)dispatcher {
30 DCHECK(dispatcher);
31 if ((self = [super init])) {
32 _dispatcher = dispatcher;
33 }
34 return self;
35 }
36
37 #pragma mark - Public
38
39 - (void)updateConsumer:(id<DialogConsumer>)consumer {
40 [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
41 [consumer setDialogMessage:[self dialogMessage]];
42 [consumer setDialogButtonItems:[self buttonItems]];
43 [consumer setDialogTextFieldItems:[self textFieldItems]];
44 }
45
46 - (void)dialogWillStart {
47 [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.
48 forProtocol:@protocol(DialogDismissalCommands)];
49 }
50
51 - (void)dialogWillStop {
52 [self.dispatcher stopDispatchingToTarget:self];
53 }
54
55 @end
56
57 @implementation DialogMediator (Internal)
58
59 - (NSString*)dialogTitle {
60 // Implemented by subclasses.
61 return nil;
62 }
63
64 - (NSString*)dialogMessage {
65 // Implemented by subclasses.
66 return nil;
67 }
68
69 - (NSArray<DialogButtonItem*>*)buttonItems {
70 // Implemented by subclasses.
71 return nil;
72 }
73
74 - (NSArray<DialogTextFieldItem*>*)textFieldItems {
75 // Implemented by subclasses.
76 return nil;
77 }
78
79 #pragma mark - DialogDismissalCommands
80
81 - (void)dismissDialogWithButtonTag:(id)buttonTag
82 userInputStrings:(NSArray<NSString*>*)inputStrings {
83 // Implemented by subclasses.
84 }
85
86 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698