diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index b579a2939..483ea7fad 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -573,6 +573,7 @@ BFF3FB9730634F37D25903F4 /* Pods_Signal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17BB5C25D615AB49813100C /* Pods_Signal.framework */; }; C31A6C5A247F214E001123EF /* UIView+Glow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31A6C59247F214E001123EF /* UIView+Glow.swift */; }; C31A6C5C247F2CF3001123EF /* CGRect+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31A6C5B247F2CF3001123EF /* CGRect+Utilities.swift */; }; + C329FEEC24F7277900B1C64C /* LightModeSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C329FEEB24F7277900B1C64C /* LightModeSheet.swift */; }; C34C8F7423A7830B00D82669 /* SpaceMono-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C34C8F7323A7830A00D82669 /* SpaceMono-Bold.ttf */; }; C353F8F9244809150011121A /* PNOptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C353F8F8244809150011121A /* PNOptionView.swift */; }; C3548F0624456447009433A8 /* PNModeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3548F0524456447009433A8 /* PNModeVC.swift */; }; @@ -1365,6 +1366,7 @@ B9EB5ABC1884C002007CBB57 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; C31A6C59247F214E001123EF /* UIView+Glow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Glow.swift"; sourceTree = ""; }; C31A6C5B247F2CF3001123EF /* CGRect+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGRect+Utilities.swift"; sourceTree = ""; }; + C329FEEB24F7277900B1C64C /* LightModeSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightModeSheet.swift; sourceTree = ""; }; C34C8F7323A7830A00D82669 /* SpaceMono-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SpaceMono-Bold.ttf"; sourceTree = ""; }; C353F8F8244809150011121A /* PNOptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNOptionView.swift; sourceTree = ""; }; C3548F0524456447009433A8 /* PNModeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNModeVC.swift; sourceTree = ""; }; @@ -2716,6 +2718,7 @@ B8BB82A4238F627000BA5194 /* HomeVC.swift */, B8CCF63E23975CFB0091D419 /* JoinPublicChatVC.swift */, B82B40872399EB0E00A248E7 /* LandingVC.swift */, + C329FEEB24F7277900B1C64C /* LightModeSheet.swift */, B85357C423A1F13800AAF6CD /* LinkDeviceVC.swift */, B85357C623A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift */, B86BD08323399ACF000F5AE3 /* Modal.swift */, @@ -3843,6 +3846,7 @@ 45A6DAD61EBBF85500893231 /* ReminderView.swift in Sources */, 34D1F0881F8678AA0066283D /* ConversationViewLayout.m in Sources */, B82B408E239DC00D00A248E7 /* DisplayNameVC.swift in Sources */, + C329FEEC24F7277900B1C64C /* LightModeSheet.swift in Sources */, 4CA485BB2232339F004B9E7D /* PhotoCaptureViewController.swift in Sources */, 34330AA31E79686200DF2FB9 /* OWSProgressView.m in Sources */, 344825C6211390C800DB4BD8 /* OWSOrphanDataCleaner.m in Sources */, diff --git a/Signal/Images.xcassets/Loki V2/Sun.imageset/Contents.json b/Signal/Images.xcassets/Loki V2/Sun.imageset/Contents.json new file mode 100644 index 000000000..4676691e4 --- /dev/null +++ b/Signal/Images.xcassets/Loki V2/Sun.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "Sun.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Signal/Images.xcassets/Loki V2/Sun.imageset/Sun.pdf b/Signal/Images.xcassets/Loki V2/Sun.imageset/Sun.pdf new file mode 100644 index 000000000..e4555bc54 Binary files /dev/null and b/Signal/Images.xcassets/Loki V2/Sun.imageset/Sun.pdf differ diff --git a/Signal/src/Loki/View Controllers/HomeVC.swift b/Signal/src/Loki/View Controllers/HomeVC.swift index 3f1564d6f..c12cf8891 100644 --- a/Signal/src/Loki/View Controllers/HomeVC.swift +++ b/Signal/src/Loki/View Controllers/HomeVC.swift @@ -183,16 +183,13 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) isViewVisible = true - let hasSeenMultiDeviceRemovalSheet = UserDefaults.standard[.hasSeenMultiDeviceRemovalSheet] - if !hasSeenMultiDeviceRemovalSheet { - let _ = FileServerAPI.getDeviceLinks(associatedWith: getUserHexEncodedPublicKey()).done(on: DispatchQueue.main) { [weak self] deviceLinks in - guard !deviceLinks.isEmpty else { return } - let multiDeviceRemovalSheet = MultiDeviceRemovalSheet() - multiDeviceRemovalSheet.modalPresentationStyle = .overFullScreen - multiDeviceRemovalSheet.modalTransitionStyle = .crossDissolve - self?.present(multiDeviceRemovalSheet, animated: true, completion: nil) - } - UserDefaults.standard[.hasSeenMultiDeviceRemovalSheet] = true + let hasSeenLightModeSheet = UserDefaults.standard[.hasSeenLightModeSheet] + if !hasSeenLightModeSheet { + let lightModeSheet = LightModeSheet() + lightModeSheet.modalPresentationStyle = .overFullScreen + lightModeSheet.modalTransitionStyle = .crossDissolve + present(lightModeSheet, animated: true, completion: nil) + UserDefaults.standard[.hasSeenLightModeSheet] = true } UserDefaults.standard[.hasLaunchedOnce] = true } diff --git a/Signal/src/Loki/View Controllers/LightModeSheet.swift b/Signal/src/Loki/View Controllers/LightModeSheet.swift new file mode 100644 index 000000000..6f956bed5 --- /dev/null +++ b/Signal/src/Loki/View Controllers/LightModeSheet.swift @@ -0,0 +1,47 @@ + +final class LightModeSheet : Sheet { + + override func populateContentView() { + // Set up image view + let imageView = UIImageView(image: #imageLiteral(resourceName: "Sun")) + // Set up title label + let titleLabel = UILabel() + titleLabel.textColor = Colors.text + titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize) + titleLabel.text = "Light Mode" + titleLabel.numberOfLines = 0 + titleLabel.lineBreakMode = .byWordWrapping + // Set up top stack view + let topStackView = UIStackView(arrangedSubviews: [ imageView, titleLabel ]) + topStackView.axis = .vertical + topStackView.spacing = Values.largeSpacing + topStackView.alignment = .center + // Set up explanation label + let explanationLabel = UILabel() + explanationLabel.textColor = Colors.text + explanationLabel.font = .systemFont(ofSize: Values.smallFontSize) + explanationLabel.text = """ + Who left the lights on? bla bla bla + + Feeling the dark side more? Just pop into the in-app settings and tap the app mode button in the top-right to toggle dark mode again. + """ + explanationLabel.numberOfLines = 0 + explanationLabel.lineBreakMode = .byWordWrapping + // Set up OK button + let okButton = Button(style: .prominentOutline, size: .large) + okButton.set(.width, to: 240) + okButton.setTitle(NSLocalizedString("OK", comment: ""), for: UIControl.State.normal) + okButton.addTarget(self, action: #selector(close), for: UIControl.Event.touchUpInside) + // Set up main stack view + let stackView = UIStackView(arrangedSubviews: [ topStackView, explanationLabel, okButton ]) + stackView.axis = .vertical + stackView.spacing = Values.veryLargeSpacing + stackView.alignment = .center + // Set up constraints + contentView.addSubview(stackView) + stackView.pin(.leading, to: .leading, of: contentView, withInset: Values.veryLargeSpacing) + stackView.pin(.top, to: .top, of: contentView, withInset: Values.largeSpacing) + contentView.pin(.trailing, to: .trailing, of: stackView, withInset: Values.veryLargeSpacing) + contentView.pin(.bottom, to: .bottom, of: stackView, withInset: Values.veryLargeSpacing + overshoot) + } +} diff --git a/Signal/src/Loki/View Controllers/PNModeVC.swift b/Signal/src/Loki/View Controllers/PNModeVC.swift index f09be912d..23c8b9f2f 100644 --- a/Signal/src/Loki/View Controllers/PNModeVC.swift +++ b/Signal/src/Loki/View Controllers/PNModeVC.swift @@ -90,6 +90,7 @@ final class PNModeVC : BaseVC, OptionViewDelegate { } UserDefaults.standard[.isUsingFullAPNs] = (selectedOptionView == apnsOptionView) UserDefaults.standard[.hasSeenMultiDeviceRemovalSheet] = true + UserDefaults.standard[.hasSeenLightModeSheet] = true TSAccountManager.sharedInstance().didRegister() let homeVC = HomeVC() navigationController!.setViewControllers([ homeVC ], animated: true) diff --git a/Signal/src/Loki/View Controllers/Sheet.swift b/Signal/src/Loki/View Controllers/Sheet.swift index 7f2ad7ccc..b34530dcd 100644 --- a/Signal/src/Loki/View Controllers/Sheet.swift +++ b/Signal/src/Loki/View Controllers/Sheet.swift @@ -11,18 +11,19 @@ class Sheet : BaseVC { result.backgroundColor = Colors.modalBackground result.layer.cornerRadius = 24 result.layer.masksToBounds = false - result.layer.borderColor = Colors.modalBorder.cgColor + result.layer.borderColor = isLightMode ? UIColor.white.cgColor : Colors.modalBorder.cgColor result.layer.borderWidth = Values.borderThickness result.layer.shadowColor = UIColor.black.cgColor - result.layer.shadowRadius = 8 - result.layer.shadowOpacity = 0.64 + result.layer.shadowRadius = isLightMode ? 2 : 8 + result.layer.shadowOpacity = isLightMode ? 0.1 : 0.64 return result }() // MARK: Lifecycle override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor(hex: 0x000000).withAlphaComponent(Values.modalBackgroundOpacity) + let alpha = isLightMode ? CGFloat(0.1) : Values.modalBackgroundOpacity + view.backgroundColor = UIColor(hex: 0x000000).withAlphaComponent(alpha) let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(close)) swipeGestureRecognizer.direction = .down view.addGestureRecognizer(swipeGestureRecognizer) diff --git a/SignalServiceKit/src/Loki/Utilities/LKUserDefaults.swift b/SignalServiceKit/src/Loki/Utilities/LKUserDefaults.swift index 9b8184df6..2fc7eaf0a 100644 --- a/SignalServiceKit/src/Loki/Utilities/LKUserDefaults.swift +++ b/SignalServiceKit/src/Loki/Utilities/LKUserDefaults.swift @@ -5,6 +5,7 @@ public enum LKUserDefaults { public enum Bool : Swift.String { case hasLaunchedOnce case hasSeenGIFMetadataWarning + case hasSeenLightModeSheet case hasSeenMultiDeviceRemovalSheet case hasSeenOpenGroupSuggestionSheet case hasViewedSeed