-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show Intro message for existing users on New Tab Page (#3173)
<!-- Note: This checklist is a reminder of our shared engineering expectations. Feel free to change it, although assigning a GitHub reviewer and the items in bold are required.⚠️ If you're an external contributor, please file an issue first before working on a PR, as we can't guarantee that we will accept your changes if they haven't been discussed ahead of time. Thanks! --> Task/Issue URL: https://app.asana.com/0/1206226850447395/1207951131408752/f Tech Design URL: CC: **Description**: Adds a message for existing users about redesign of New Tab Page. I'm using the presence of install date during app launch to determine if the user is new. Existing implementation also checks whether the feature flag is set to be releasable remotely and does nothing if it is not. Altering the code is necessary to verify final behavior. **Steps to test this PR**: 1. Install and run any other build (without the intro message). If you have any other build run already you can skip this step. 1. Change `NewTabPageManager.isAvailableInPublicRelease` to return `true`, to override setup restrictions. Run build from this branch. 1. Set _internal user state_ and enable New Tab Page Sections feature flag in Debug menu. 1. Intro message should be visible on new tab page as well as for next two new tab page impressions. 1. Tapping on X button should hide message forever. 1. Remove app. 1. Launch and enable the feature in Debug menu again - intro message should not be visible. **Finally:** With code unchanged message should not initialize at all. It can be reset and verified in Debug menu.
- Loading branch information
Showing
41 changed files
with
615 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// NewTabPageIntroMessageSetup.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import BrowserServicesKit | ||
import Core | ||
|
||
struct NewTabPageIntroMessageSetup { | ||
let appSettings: AppSettings | ||
let statistics: StatisticsStore | ||
let newTabPageManager: NewTabPageManaging | ||
|
||
init(appSettings: AppSettings = AppDependencyProvider.shared.appSettings, | ||
statistics: StatisticsStore = StatisticsUserDefaults(), | ||
newTabPageManager: NewTabPageManaging = NewTabPageManager()) { | ||
self.appSettings = appSettings | ||
self.statistics = statistics | ||
self.newTabPageManager = newTabPageManager | ||
} | ||
|
||
func perform() { | ||
|
||
let isNotSetUp = appSettings.newTabPageIntroMessageEnabled == nil | ||
guard newTabPageManager.isAvailableInPublicRelease && isNotSetUp else { return } | ||
|
||
// For new users we **don't** want intro message | ||
appSettings.newTabPageIntroMessageEnabled = statistics.installDate != nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// NewTabPageIntroMessageView.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
import DesignResourcesKit | ||
|
||
struct NewTabPageIntroMessageView: View { | ||
|
||
var onClose: (() -> Void)? | ||
|
||
var body: some View { | ||
VStack { | ||
VStack(spacing: Metrics.itemSpacing) { | ||
HStack { | ||
Text(UserText.newTabPageIntroMessageTitle) | ||
.daxHeadline() | ||
.multilineTextAlignment(.center) | ||
.foregroundStyle(Color(designSystemColor: .textPrimary)) | ||
.frame(maxWidth: .infinity, alignment: .top) | ||
} | ||
.padding(.horizontal, Metrics.titlePadding) // Prevent showing header underneath close button | ||
|
||
Text(UserText.newTabPageIntroMessageBody) | ||
.foregroundStyle(Color(designSystemColor: .textPrimary)) | ||
.daxBodyRegular() | ||
.multilineTextAlignment(.center) | ||
} | ||
.padding(Metrics.padding) | ||
.overlay(alignment: .topTrailing) { | ||
Button { | ||
onClose?() | ||
} label: { | ||
Image(.close24) | ||
} | ||
.frame(alignment: .topTrailing) | ||
.foregroundStyle(Color(designSystemColor: .icons)) | ||
} | ||
} | ||
.padding(Metrics.padding) | ||
.frame(maxWidth: .infinity, alignment: .center) | ||
.background(Color(designSystemColor: .surface)) | ||
.cornerRadius(Metrics.cornerRadius) | ||
.shadow(color: .shade(0.1), radius: 2, x: 0, y: 1) | ||
} | ||
|
||
private enum Metrics { | ||
static let padding = 8.0 | ||
static let itemSpacing = 6.0 | ||
static let cornerRadius = 12.0 | ||
static let titlePadding = 20.0 | ||
} | ||
} | ||
|
||
#Preview { | ||
VStack { | ||
NewTabPageIntroMessageView().padding(16) | ||
} | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.background(Color(designSystemColor: .background)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// NewTabPageModel.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
final class NewTabPageModel: ObservableObject { | ||
|
||
@Published private(set) var isIntroMessageVisible: Bool | ||
|
||
private let appSettings: AppSettings | ||
|
||
init(appSettings: AppSettings = AppDependencyProvider.shared.appSettings) { | ||
self.appSettings = appSettings | ||
|
||
isIntroMessageVisible = appSettings.newTabPageIntroMessageEnabled ?? false | ||
} | ||
|
||
func increaseIntroMessageCounter() { | ||
appSettings.newTabPageIntroMessageSeenCount += 1 | ||
if appSettings.newTabPageIntroMessageSeenCount >= 3 { | ||
appSettings.newTabPageIntroMessageEnabled = false | ||
} | ||
} | ||
|
||
func dismissIntroMessage() { | ||
appSettings.newTabPageIntroMessageEnabled = false | ||
isIntroMessageVisible = false | ||
} | ||
} |
Oops, something went wrong.