WIP - attachment caption

pull/1/head
Michael Kirk 8 years ago committed by sdkjfhsdkjhfsdlkjhfsdf
parent 76481a86a5
commit 57a5e62db8

@ -53,7 +53,7 @@ static NSString *const kInitialViewControllerIdentifier = @"UserInitialViewContr
static NSString *const kURLSchemeSGNLKey = @"sgnl"; static NSString *const kURLSchemeSGNLKey = @"sgnl";
static NSString *const kURLHostVerifyPrefix = @"verify"; static NSString *const kURLHostVerifyPrefix = @"verify";
@interface AppDelegate () @interface AppDelegate () <AttachmentApprovalViewControllerDelegate>
@property (nonatomic) UIWindow *screenProtectionWindow; @property (nonatomic) UIWindow *screenProtectionWindow;
@property (nonatomic) BOOL hasInitialRootViewController; @property (nonatomic) BOOL hasInitialRootViewController;
@ -805,10 +805,21 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
DDLogInfo(@"Presenting initial root view controller"); DDLogInfo(@"Presenting initial root view controller");
if ([TSAccountManager isRegistered]) { if ([TSAccountManager isRegistered]) {
HomeViewController *homeView = [HomeViewController new]; // DO NOT COMMIT
SignalsNavigationController *navigationController = SignalAttachment *_Nullable attachment = [SignalAttachment attachmentFromPasteboard];
[[SignalsNavigationController alloc] initWithRootViewController:homeView]; if (!attachment.hasError) {
self.window.rootViewController = navigationController; AttachmentApprovalViewController *approvalVC =
[[AttachmentApprovalViewController alloc] initWithAttachment:attachment delegate:self];
UINavigationController *approvalNavController =
[[UINavigationController alloc] initWithRootViewController:approvalVC];
approvalNavController.navigationBarHidden = YES;
self.window.rootViewController = approvalNavController;
} else {
HomeViewController *homeView = [HomeViewController new];
SignalsNavigationController *navigationController =
[[SignalsNavigationController alloc] initWithRootViewController:homeView];
self.window.rootViewController = navigationController;
}
} else { } else {
RegistrationViewController *viewController = [RegistrationViewController new]; RegistrationViewController *viewController = [RegistrationViewController new];
OWSNavigationController *navigationController = OWSNavigationController *navigationController =
@ -820,4 +831,16 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[AppUpdateNag.sharedInstance showAppUpgradeNagIfNecessary]; [AppUpdateNag.sharedInstance showAppUpgradeNagIfNecessary];
} }
- (void)didApproveAttachmentWithAttachment:(SignalAttachment *_Nonnull)attachment
{
DDLogVerbose(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
[self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)didCancelAttachmentWithAttachment:(SignalAttachment *_Nonnull)attachment
{
DDLogVerbose(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
[self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
}
@end @end

@ -21,9 +21,10 @@ public class AttachmentApprovalViewController: OWSViewController {
let attachment: SignalAttachment let attachment: SignalAttachment
private(set) var bottomToolbar: UIToolbar! private(set) var bottomToolbar: UIView!
private(set) var mediaMessageView: MediaMessageView! private(set) var mediaMessageView: MediaMessageView!
private(set) var scrollView: UIScrollView! private(set) var scrollView: UIScrollView!
private var textField: UITextField!
// MARK: Initializers // MARK: Initializers
@ -170,10 +171,12 @@ public class AttachmentApprovalViewController: OWSViewController {
topToolbar.items = [cancelButton] topToolbar.items = [cancelButton]
// Bottom Toolbar // Bottom Toolbar
self.bottomToolbar = makeClearToolbar() let bottomToolbar: UIToolbar = makeClearToolbar()
// Making a toolbar transparent requires setting an empty uiimage self.bottomToolbar = bottomToolbar
bottomToolbar.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default) self.textField = UITextField()
bottomToolbar.backgroundColor = UIColor.clear let textFieldItem = UIBarButtonItem(customView: textField)
// textField.autoresizingMask = [.flexibleWidth, .flexibleHeight];
textField.translatesAutoresizingMaskIntoConstraints = false
let sendTitle = NSLocalizedString("ATTACHMENT_APPROVAL_SEND_BUTTON", comment: "Label for 'send' button in the 'attachment approval' dialog.") let sendTitle = NSLocalizedString("ATTACHMENT_APPROVAL_SEND_BUTTON", comment: "Label for 'send' button in the 'attachment approval' dialog.")
let sendButton = UIBarButtonItem(title: sendTitle, let sendButton = UIBarButtonItem(title: sendTitle,
@ -183,13 +186,83 @@ public class AttachmentApprovalViewController: OWSViewController {
sendButton.tintColor = UIColor.white sendButton.tintColor = UIColor.white
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
bottomToolbar.items = [flexibleSpace, sendButton] bottomToolbar.items = [textFieldItem, sendButton]
// bottomToolbar.items = [flexibleSpace, sendButton]
bottomToolbar.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default)
bottomToolbar.backgroundColor = UIColor.clear
bottomToolbar.autoSetDimension(.height, toSize: 40)
// self.bottomToolbar = MessagingToolbar()
// Making a toolbar transparent requires setting an empty uiimage
// self.view.addSubview(bottomToolbar)
// bottomToolbar.autoPin(toBottomLayoutGuideOf: self, withInset: 0)
// bottomToolbar.autoPinWidthToSuperview()
// bottomToolbar.setCompressionResistanceVerticalHigh()
// bottomToolbar.setContentHuggingVerticalHigh()
}
override public var inputAccessoryView: UIView? {
return self.bottomToolbar
}
override public var canBecomeFirstResponder: Bool {
return true
}
class MessagingToolbar: UIToolbar {
let sendButton: UIButton
let textField: UITextField
self.view.addSubview(bottomToolbar) init() {
bottomToolbar.autoPin(toBottomLayoutGuideOf: self, withInset: 0) self.sendButton = UIButton(type: .system)
bottomToolbar.autoPinWidthToSuperview() self.sendButton.setTitle("Send", for: .normal)
bottomToolbar.setCompressionResistanceVerticalHigh() self.sendButton.tintColor = UIColor.white
bottomToolbar.setContentHuggingVerticalHigh()
self.textField = UITextField()
textField.backgroundColor = UIColor.white
textField.layer.cornerRadius = 2.0
super.init(frame: CGRect.zero)
backgroundColor = UIColor.green
addSubview(sendButton)
addSubview(textField)
// textField.autoPinEdge(toSuperviewEdge: .leading, withInset: 4.0)
// textField.autoPinEdge(.trailing, to: .leading, of: sendButton, withOffset: -4.0)
// textField.autoPinHeightToSuperview(withMargin: 2.0)
// sendButton.autoPinEdge(toSuperviewEdge: .trailing, withInset: 4.0)
// sendButton.autoPinHeightToSuperview(withMargin: 2.0)
// self.autoSetDimension(.height, toSize: 40, relation: .greaterThanOrEqual)
}
override func layoutSubviews() {
super.layoutSubviews()
let kMargin = 4
let kTextFieldHeight = 40
let kTextFieldWidth = 200
let kSendButtonHeight = 40
let kSendButtonWidth = 100
self.textField.frame = CGRect(x: kMargin, y: kMargin, width: kTextFieldWidth, height: kTextFieldHeight)
self.sendButton.frame = CGRect(x: kMargin * 2 + kTextFieldWidth, y: kMargin, width: kSendButtonWidth, height: kSendButtonHeight)
self.frame = CGRect(x: 0, y: 0, width: 320, height: kTextFieldHeight + 2 * kMargin)
self.bounds = self.frame
// self.textField.sizeToFit()
// let maxHeight = max(self.sendButton.frame.size.height, self.textField.frame.size.height)
// let fittedFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.size.width, height: maxHeight)
// self.frame = fittedFrame
// self.bounds = fittedFrame
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
} }
private func makeClearToolbar() -> UIToolbar { private func makeClearToolbar() -> UIToolbar {

Loading…
Cancel
Save