Show light mode announcement sheet to existing users

This commit is contained in:
nielsandriesse 2020-08-27 10:16:38 +10:00
parent 717d44c204
commit 44ca8c293a
8 changed files with 77 additions and 14 deletions

View File

@ -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 = "<group>"; };
C31A6C5B247F2CF3001123EF /* CGRect+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGRect+Utilities.swift"; sourceTree = "<group>"; };
C329FEEB24F7277900B1C64C /* LightModeSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightModeSheet.swift; sourceTree = "<group>"; };
C34C8F7323A7830A00D82669 /* SpaceMono-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SpaceMono-Bold.ttf"; sourceTree = "<group>"; };
C353F8F8244809150011121A /* PNOptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNOptionView.swift; sourceTree = "<group>"; };
C3548F0524456447009433A8 /* PNModeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNModeVC.swift; sourceTree = "<group>"; };
@ -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 */,

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Sun.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

View File

@ -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
}

View File

@ -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)
}
}

View File

@ -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)

View File

@ -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)

View File

@ -5,6 +5,7 @@ public enum LKUserDefaults {
public enum Bool : Swift.String {
case hasLaunchedOnce
case hasSeenGIFMetadataWarning
case hasSeenLightModeSheet
case hasSeenMultiDeviceRemovalSheet
case hasSeenOpenGroupSuggestionSheet
case hasViewedSeed