-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
new_tab_page_header_view.h
83 lines (63 loc) · 3.41 KB
/
new_tab_page_header_view.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_HEADER_VIEW_H_
#define IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_HEADER_VIEW_H_
#import <UIKit/UIKit.h>
// Header view for the NTP. The header view contains all views that are
// displayed above the list of most visited sites, which includes the
// primary toolbar, doodle, and fake omnibox.
@interface NewTabPageHeaderView : UIView
// Returns the toolbar view.
@property(nonatomic, readonly) UIView* toolBarView;
// The Identity Disc showing the current user's avatar on NTP.
@property(nonatomic, strong) UIView* identityDiscView;
// Voice search button.
@property(nonatomic, strong, readonly) UIButton* voiceSearchButton;
// The button that opens Lens. May be nil if Lens is not enabled.
@property(nonatomic, strong, readonly) UIButton* lensButton;
// Fake cancel button, used for animations. Hidden by default.
@property(nonatomic, strong) UIView* cancelButton;
// Fake omnibox, used for animations. Hidden by default.
@property(nonatomic, strong) UIView* omnibox;
@property(nonatomic, strong)
NSLayoutConstraint* fakeLocationBarLeadingConstraint;
@property(nonatomic, strong)
NSLayoutConstraint* fakeLocationBarTrailingConstraint;
@property(nonatomic, strong) UIView* fakeLocationBar;
@property(nonatomic, strong) UILabel* searchHintLabel;
// `YES` if Google is the default search engine.
@property(nonatomic, assign) BOOL isGoogleDefaultSearchEngine;
// Adds the separator to the searchField. Must be called after the searchField
// is added as a subview.
- (void)addSeparatorToSearchField:(UIView*)searchField;
// Adds the `toolbarView` to the view implementing this protocol.
// Can only be added once.
- (void)addToolbarView:(UIView*)toolbarView;
// Returns the progress of the search field position along
// `ntp_header::kAnimationDistance` as the offset changes.
- (CGFloat)searchFieldProgressForOffset:(CGFloat)offset
safeAreaInsets:(UIEdgeInsets)safeAreaInsets;
// The positive offset value to begin the fake omniobx expansion animation.
- (CGFloat)offsetToBeginFakeOmniboxExpansionForSplitMode;
// Changes the constraints of searchField based on its initialFrame and the
// scroll view's y `offset`. Also adjust the alpha values for `_searchBoxBorder`
// and `_shadow` and the constant values for the `constraints`. `screenWidth` is
// the width of the screen, including the space outside the safe area. The
// `safeAreaInsets` is relative to the view used to calculate the `width`.
- (void)updateSearchFieldWidth:(NSLayoutConstraint*)widthConstraint
height:(NSLayoutConstraint*)heightConstraint
topMargin:(NSLayoutConstraint*)topMarginConstraint
forOffset:(CGFloat)offset
screenWidth:(CGFloat)screenWidth
safeAreaInsets:(UIEdgeInsets)safeAreaInsets;
// Adds views necessary to customize the NTP search box.
- (void)addViewsToSearchField:(UIView*)searchField;
// Highlights the fake omnibox.
- (void)setFakeboxHighlighted:(BOOL)highlighted;
// Updates the different constraints using `topSafeAreaInset`. This is needed
// because sometimes the safe area isn't correctly updated. See
// crbug.com/1041831.
- (void)updateForTopSafeAreaInset:(CGFloat)topSafeAreaInset;
@end
#endif // IOS_CHROME_BROWSER_UI_NTP_NEW_TAB_PAGE_HEADER_VIEW_H_