mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Fix ref duration
This commit is contained in:
@@ -176,10 +176,10 @@ final class AffiliateProgramSetupScreenComponent: Component {
|
||||
let programPermille: Int32 = Int32(self.commissionPermille)
|
||||
let programDuration: Int32? = self.durationValue == Int(Int32.max) ? nil : Int32(self.durationValue)
|
||||
|
||||
let commissionTitle: String = "\(programPermille / 10)%"
|
||||
let commissionTitle: String = "\(formatPermille(programPermille))%"
|
||||
let durationTitle: String
|
||||
if let durationMonths = programDuration {
|
||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (24 * 60 * 60))
|
||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (30 * 24 * 60 * 60))
|
||||
} else {
|
||||
durationTitle = "Lifetime"
|
||||
}
|
||||
@@ -378,7 +378,7 @@ If you end your affiliate program:
|
||||
}
|
||||
UIPasteboard.general.string = bot.url
|
||||
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 })
|
||||
self.environment?.controller()?.present(UndoOverlayController(presentationData: presentationData, content: .linkCopied(title: "Link copied to clipboard", text: "Share this link and earn **\(bot.commissionPermille / 10)%** of what people who use it spend in **\(bot.peer.compactDisplayTitle)**!"), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
|
||||
self.environment?.controller()?.present(UndoOverlayController(presentationData: presentationData, content: .linkCopied(title: "Link copied to clipboard", text: "Share this link and earn **\(formatPermille(bot.commissionPermille))%** of what people who use it spend in **\(bot.peer.compactDisplayTitle)**!"), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
|
||||
}
|
||||
))
|
||||
))
|
||||
@@ -557,13 +557,15 @@ If you end your affiliate program:
|
||||
self.commissionPermille = 10
|
||||
self.commissionSliderValue = 0.0
|
||||
self.commissionMinPermille = 10
|
||||
self.durationValue = 10
|
||||
self.durationValue = 1
|
||||
self.durationMinValue = 0
|
||||
}
|
||||
} else {
|
||||
self.commissionPermille = 10
|
||||
self.commissionSliderValue = 0.0
|
||||
self.commissionMinPermille = 10
|
||||
self.durationValue = 10
|
||||
self.durationValue = 1
|
||||
self.durationMinValue = 0
|
||||
}
|
||||
case .connectedPrograms:
|
||||
self.connectedStarBotListDisposable = (component.context.engine.peers.requestConnectedStarRefBots(
|
||||
@@ -875,7 +877,7 @@ If you end your affiliate program:
|
||||
minValue: commissionMinSliderValue,
|
||||
lowerBoundTitle: "1%",
|
||||
upperBoundTitle: "90%",
|
||||
title: "\(self.commissionPermille / 10)%",
|
||||
title: "\(formatPermille(self.commissionPermille))%",
|
||||
valueUpdated: { [weak self] value in
|
||||
guard let self else {
|
||||
return
|
||||
@@ -1183,11 +1185,11 @@ If you end your affiliate program:
|
||||
for item in connectedStarBotList.items {
|
||||
let durationTitle: String
|
||||
if let durationMonths = item.durationMonths {
|
||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (24 * 60 * 60))
|
||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (30 * 24 * 60 * 60))
|
||||
} else {
|
||||
durationTitle = "Lifetime"
|
||||
}
|
||||
let commissionTitle = "\(item.commissionPermille / 10)%"
|
||||
let commissionTitle = "\(formatPermille(item.commissionPermille))%"
|
||||
|
||||
let itemContextAction: (EnginePeer, ContextExtractedContentContainingView, ContextGesture?) -> Void = { [weak self] peer, sourceView, gesture in
|
||||
guard let self, let component = self.component, let environment = self.environment else {
|
||||
@@ -1249,7 +1251,7 @@ If you end your affiliate program:
|
||||
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 })
|
||||
|
||||
UIPasteboard.general.string = item.url
|
||||
environment.controller()?.present(UndoOverlayController(presentationData: presentationData, content: .linkCopied(title: "Link copied to clipboard", text: "Share this link and earn **\(item.commissionPermille / 10)%** of what people who use it spend in **\(item.peer.compactDisplayTitle)**!"), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
|
||||
environment.controller()?.present(UndoOverlayController(presentationData: presentationData, content: .linkCopied(title: "Link copied to clipboard", text: "Share this link and earn **\(formatPermille(item.commissionPermille))%** of what people who use it spend in **\(item.peer.compactDisplayTitle)**!"), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
|
||||
})))
|
||||
|
||||
itemList.append(.action(ContextMenuActionItem(text: "Leave", textColor: .destructive, icon: { theme in
|
||||
@@ -1364,17 +1366,21 @@ If you end your affiliate program:
|
||||
do {
|
||||
var suggestedSectionItems: [AnyComponentWithIdentity<Empty>] = []
|
||||
if suggestedStarBotListItems.isEmpty {
|
||||
suggestedSectionItems.append(AnyComponentWithIdentity(id: "empty", component: AnyComponent(TransformContents(
|
||||
content: AnyComponent(),
|
||||
fixedSize: CGSize(width: 1.0, height: 100.0),
|
||||
translation: CGPoint()
|
||||
))))
|
||||
suggestedSectionItems.append(AnyComponentWithIdentity(id: "empty", component: AnyComponent(ZStack([
|
||||
AnyComponentWithIdentity(id: 0, component: AnyComponent(Rectangle(color: .clear, width: nil, height: 100.0))),
|
||||
AnyComponentWithIdentity(id: 1, component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: "No available programs yet.\nPlease check the page later.", font: Font.regular(15.0), textColor: environment.theme.list.itemSecondaryTextColor)),
|
||||
horizontalAlignment: .center,
|
||||
maximumNumberOfLines: 0,
|
||||
lineSpacing: 0.2
|
||||
)))
|
||||
]))))
|
||||
}
|
||||
for item in suggestedStarBotListItems {
|
||||
let commissionTitle = "\(item.program.commissionPermille / 10)%"
|
||||
let commissionTitle = "\(formatPermille(item.program.commissionPermille))%"
|
||||
let durationTitle: String
|
||||
if let durationMonths = item.program.durationMonths {
|
||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (24 * 60 * 60))
|
||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (30 * 24 * 60 * 60))
|
||||
} else {
|
||||
durationTitle = "Lifetime"
|
||||
}
|
||||
@@ -1467,31 +1473,34 @@ If you end your affiliate program:
|
||||
))))
|
||||
}
|
||||
|
||||
var suggestedHeaderItems: [AnyComponentWithIdentity<Empty>] = []
|
||||
suggestedHeaderItems.append(AnyComponentWithIdentity(id: 0, component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(
|
||||
string: "PROGRAMS",
|
||||
font: Font.regular(13.0),
|
||||
textColor: environment.theme.list.freeTextColor
|
||||
)),
|
||||
maximumNumberOfLines: 0
|
||||
))))
|
||||
if suggestedStarBotListItems.count > 1 {
|
||||
suggestedHeaderItems.append(AnyComponentWithIdentity(id: 1, component: AnyComponent(BotSectionSortButtonComponent(
|
||||
theme: environment.theme,
|
||||
strings: environment.strings,
|
||||
sortMode: self.suggestedSortMode,
|
||||
action: { [weak self] sourceView in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.openSortModeMenu(sourceView: sourceView)
|
||||
}
|
||||
))))
|
||||
}
|
||||
|
||||
let suggestedProgramsSectionSize = self.suggestedProgramsSection.update(
|
||||
transition: transition,
|
||||
component: AnyComponent(ListSectionComponent(
|
||||
theme: environment.theme,
|
||||
header: AnyComponent(HStack([
|
||||
AnyComponentWithIdentity(id: 0, component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(
|
||||
string: "PROGRAMS",
|
||||
font: Font.regular(13.0),
|
||||
textColor: environment.theme.list.freeTextColor
|
||||
)),
|
||||
maximumNumberOfLines: 0
|
||||
))),
|
||||
AnyComponentWithIdentity(id: 1, component: AnyComponent(BotSectionSortButtonComponent(
|
||||
theme: environment.theme,
|
||||
strings: environment.strings,
|
||||
sortMode: self.suggestedSortMode,
|
||||
action: { [weak self] sourceView in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.openSortModeMenu(sourceView: sourceView)
|
||||
}
|
||||
)))
|
||||
], spacing: 4.0, alignment: .alternatingLeftRight)),
|
||||
header: AnyComponent(HStack(suggestedHeaderItems, spacing: 4.0, alignment: .alternatingLeftRight)),
|
||||
footer: nil,
|
||||
items: suggestedSectionItems,
|
||||
displaySeparators: true
|
||||
@@ -1506,19 +1515,12 @@ If you end your affiliate program:
|
||||
self.scrollView.addSubview(suggestedProgramsSectionView)
|
||||
}
|
||||
transition.setFrame(view: suggestedProgramsSectionView, frame: suggestedProgramsSectionFrame)
|
||||
if !suggestedStarBotListItems.isEmpty {
|
||||
suggestedProgramsSectionView.isHidden = false
|
||||
} else {
|
||||
suggestedProgramsSectionView.isHidden = true
|
||||
}
|
||||
|
||||
suggestedProgramsSectionView.contentViewImpl.alpha = self.isSuggestedSortModeUpdating ? 0.6 : 1.0
|
||||
suggestedProgramsSectionView.contentViewImpl.isUserInteractionEnabled = !self.isSuggestedSortModeUpdating
|
||||
}
|
||||
if !suggestedStarBotListItems.isEmpty {
|
||||
contentHeight += suggestedProgramsSectionSize.height
|
||||
contentHeight += sectionSpacing
|
||||
}
|
||||
contentHeight += suggestedProgramsSectionSize.height
|
||||
contentHeight += sectionSpacing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ private final class JoinAffiliateProgramScreenComponent: Component {
|
||||
))
|
||||
),
|
||||
AnyComponentWithIdentity(id: 1, component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: "\(component.commissionPermille / 10)%", font: Font.regular(13.0), textColor: environment.theme.list.itemCheckColors.foregroundColor))
|
||||
text: .plain(NSAttributedString(string: "\(formatPermille(component.commissionPermille))%", font: Font.regular(13.0), textColor: environment.theme.list.itemCheckColors.foregroundColor))
|
||||
)))
|
||||
], spacing: 2.0)),
|
||||
insets: UIEdgeInsets(top: 3.0, left: 6.0, bottom: 3.0, right: 6.0),
|
||||
@@ -766,7 +766,7 @@ private final class JoinAffiliateProgramScreenComponent: Component {
|
||||
contentHeight += linkIconBackgroundSize.height + 21.0
|
||||
}
|
||||
|
||||
let commissionTitle = "\(component.commissionPermille / 10)%"
|
||||
let commissionTitle = "\(formatPermille(component.commissionPermille))%"
|
||||
let durationTitle: String
|
||||
if let durationMonths = component.programDuration {
|
||||
durationTitle = timeIntervalString(strings: environment.strings, value: durationMonths * (24 * 60 * 60))
|
||||
|
||||
Reference in New Issue
Block a user