blob: 9632ea7dfe001cb4a0e78be829493355f36e79ae (
plain)
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
|
// Copyright 2014 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/chrome/browser/passwords/password_generation_edit_view.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "ios/chrome/browser/passwords/password_generation_utils.h"
namespace {
// Constants for the edit view.
const CGFloat kEditViewFontSize = 15;
} // namespace
@implementation PasswordGenerationEditView {
base::scoped_nsobject<UITextField> _textField;
}
- (instancetype)initWithPassword:(NSString*)password {
// Frame size will updated later.
const CGRect defaultFrameSize = CGRectMake(0, 0, 100, 30);
self = [super initWithFrame:defaultFrameSize];
if (self) {
_textField.reset([[UITextField alloc] init]);
[_textField setText:password];
[_textField setFont:[UIFont systemFontOfSize:kEditViewFontSize]];
[_textField setBackgroundColor:[UIColor clearColor]];
[_textField sizeToFit];
[_textField setUserInteractionEnabled:NO];
[_textField setFrame:passwords::GetGenerationAccessoryFrame(
[self bounds], [_textField frame])];
[_textField setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleWidth];
[self addSubview:_textField];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
NOTREACHED();
return nil;
}
- (instancetype)initWithCoder:(NSCoder*)aDecoder {
NOTREACHED();
return nil;
}
@end
|