2026-03-25 23:57:52 +08:00
import QtQuick
import QtQuick . Controls
import QtQuick . Layouts
import Style 1.0
import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
2026-03-26 20:03:18 +08:00
import PageEnum 1.0
2026-03-25 23:57:52 +08:00
PageType {
id: root
2026-03-26 14:53:45 +08:00
property int selectedPlanIndex: 0
2026-03-25 23:57:52 +08:00
property string premiumHeaderName: ""
property string premiumHeaderDescription: ""
2026-03-26 20:03:18 +08:00
readonly property var currentPlan: ApiSubscriptionPlansModel . planAt ( selectedPlanIndex )
2026-03-25 23:57:52 +08:00
function syncFromModel ( ) {
2026-03-26 20:03:18 +08:00
root . selectedPlanIndex = ApiSubscriptionPlansModel . recommendedRowIndex ( )
2026-03-25 23:57:52 +08:00
root . premiumHeaderName = String ( ApiServicesModel . getSelectedServiceData ( "name" ) )
root . premiumHeaderDescription = String ( ApiServicesModel . getSelectedServiceData ( "serviceDescription" ) )
}
Component.onCompleted: syncFromModel ( )
BackButtonType {
id: backButton
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
anchors.topMargin: 20 + SettingsController . safeAreaTopMargin
onFocusChanged: {
if ( activeFocus ) {
flick . contentY = 0
}
}
}
FlickableType {
id: flick
anchors.top: backButton . bottom
anchors.bottom: continueButton . top
anchors.left: parent . left
anchors.right: parent . right
contentHeight: scrollColumn . implicitHeight + 24
ColumnLayout {
id: scrollColumn
width: flick . width
spacing: 0
BaseHeaderType {
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 24
headerText: root . premiumHeaderName
descriptionText: root . premiumHeaderDescription
}
Repeater {
2026-03-26 20:03:18 +08:00
model: ApiSubscriptionPlansModel
2026-03-25 23:57:52 +08:00
delegate: SubscriptionPlanCard {
required property int index
2026-03-26 20:03:18 +08:00
required property var model
2026-03-25 23:57:52 +08:00
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2026-03-26 20:03:18 +08:00
Layout.bottomMargin: index === ApiSubscriptionPlansModel . rowCount ( ) - 1 ? 24 : 12
2026-03-25 23:57:52 +08:00
2026-03-26 14:53:45 +08:00
selected: root . selectedPlanIndex === index
2026-03-31 16:17:55 +08:00
billingPeriod: String ( model . billingPeriod )
priceLabel: String ( model . priceLabel )
2026-03-26 17:16:41 +08:00
subtitle: String ( model . subtitle )
showRecommendedBadge: ! ! model . recommended
2026-03-25 23:57:52 +08:00
recommendedText: qsTr ( "Recommended" )
2026-03-26 14:53:45 +08:00
onSelectRequested: root . selectedPlanIndex = index
2026-03-25 23:57:52 +08:00
}
}
LabelTextType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 12
text: qsTr ( "Premium features" )
color: AmneziaStyle . color . mutedGray
font.pixelSize: 13
}
BenefitsPanel {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 24
2026-03-26 20:03:18 +08:00
benefitsModel: ApiBenefitsModel
2026-03-25 23:57:52 +08:00
}
2026-03-30 19:21:27 +08:00
ColumnLayout {
2026-03-25 23:57:52 +08:00
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
2026-03-30 19:21:27 +08:00
Layout.bottomMargin: 24
visible: Qt . platform . os === "ios" || IsMacOsNeBuild
spacing: 16
2026-03-25 23:57:52 +08:00
2026-03-30 19:21:27 +08:00
ParagraphTextType {
Layout.fillWidth: true
horizontalAlignment: Text . AlignHCenter
textFormat: Text . PlainText
color: AmneziaStyle . color . mutedGray
font.pixelSize: 12
2026-03-25 23:57:52 +08:00
2026-03-30 19:21:27 +08:00
text: qsTr ( "Charged to your Apple ID at confirmation. Renews automatically unless auto-renew is turned off at least 24 hours before period end. Manage in Apple ID settings." )
2026-03-25 23:57:52 +08:00
}
2026-03-30 19:21:27 +08:00
ParagraphTextType {
Layout.fillWidth: true
horizontalAlignment: Text . AlignHCenter
textFormat: Text . RichText
color: AmneziaStyle . color . mutedGray
font.pixelSize: 12
text: {
var termsUrl = "https://www.apple.com/legal/internet-services/itunes/dev/stdeula/"
var privacyUrl = LanguageModel . getCurrentSiteUrl ( "policy" )
return qsTr ( "By continuing, you agree to the <a href=\"%1\" style=\"color: %3;\">Terms of Use</a> and <a href=\"%2\" style=\"color: %3;\">Privacy Policy</a>" )
. arg ( termsUrl ) . arg ( privacyUrl ) . arg ( AmneziaStyle . color . goldenApricotString )
}
onLinkActivated: function ( link ) {
Qt . openUrlExternally ( link )
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt . NoButton
cursorShape: parent . hoveredLink ? Qt.PointingHandCursor : Qt . ArrowCursor
}
2026-03-25 23:57:52 +08:00
}
}
ParagraphTextType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 24
2026-03-30 19:21:27 +08:00
visible: ! ( Qt . platform . os === "ios" || IsMacOsNeBuild )
2026-03-25 23:57:52 +08:00
horizontalAlignment: Text . AlignHCenter
textFormat: Text . RichText
color: AmneziaStyle . color . mutedGray
font.pixelSize: 12
text: {
2026-03-26 17:16:41 +08:00
return qsTr ( "By continuing, you agree to the <a href=\"%1\" style=\"color: %3;\">Terms of Use</a> and <a href=\"%2\" style=\"color: %3;\">Privacy Policy</a>" )
2026-03-30 19:21:27 +08:00
. arg ( String ( ApiServicesModel . getSelectedServiceData ( "termsOfUseUrl" ) ) )
. arg ( String ( ApiServicesModel . getSelectedServiceData ( "privacyPolicyUrl" ) ) )
. arg ( AmneziaStyle . color . goldenApricotString )
2026-03-25 23:57:52 +08:00
}
onLinkActivated: function ( link ) {
Qt . openUrlExternally ( link )
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt . NoButton
cursorShape: parent . hoveredLink ? Qt.PointingHandCursor : Qt . ArrowCursor
}
}
}
}
BasicButtonType {
id: continueButton
z: 2
anchors.left: parent . left
anchors.right: parent . right
anchors.bottom: parent . bottom
anchors.leftMargin: 16
anchors.rightMargin: 16
anchors.bottomMargin: 16 + SettingsController . safeAreaBottomMargin
text: {
2026-03-26 14:53:45 +08:00
var plan = root . currentPlan
2026-03-25 23:57:52 +08:00
if ( ! plan ) {
return qsTr ( "Continue" )
}
2026-03-31 16:17:55 +08:00
return qsTr ( "Subscribe — %1 for %2" ) . arg ( String ( plan . billingPeriod ) ) . arg ( String ( plan . priceLabel ) )
2026-03-25 23:57:52 +08:00
}
clickedFunc: function ( ) {
2026-03-26 14:53:45 +08:00
var plan = root . currentPlan
2026-03-25 23:57:52 +08:00
if ( ! plan ) {
return
}
2026-03-26 20:03:18 +08:00
if ( plan . isTrial ) {
PageController . goToPage ( PageEnum . PageSetupWizardApiTrialEmail )
return
}
2026-03-31 16:12:34 +08:00
if ( Qt . platform . os === "ios" || IsMacOsNeBuild ) {
PageController . showBusyIndicator ( true )
var storeId = plan . storeProductId !== undefined ? String ( plan . storeProductId ) : ""
2026-04-01 14:25:47 +08:00
ApiConfigsController . importPremiumFromAppStore ( storeId )
2026-03-31 16:12:34 +08:00
PageController . showBusyIndicator ( false )
return
}
2026-03-26 17:16:41 +08:00
if ( plan . checkoutUrl ) {
Qt . openUrlExternally ( plan . checkoutUrl )
2026-03-25 23:57:52 +08:00
PageController . closePage ( )
PageController . closePage ( )
return
}
}
}
}