mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Various improvements
This commit is contained in:
parent
6fdd2ebf0d
commit
2aeeaaee44
@ -9428,10 +9428,6 @@ Sorry for the inconvenience.";
|
||||
|
||||
"MediaPicker.AddImage" = "Add Image";
|
||||
|
||||
"Premium.Stories" = "Story Posting";
|
||||
"Premium.StoriesInfo" = "Be one of the first to share your stories with your contacts or an unlimited audience.";
|
||||
"Premium.Stories.Proceed" = "Unlock Story Posting";
|
||||
|
||||
"AutoDownloadSettings.OnForContacts" = "On for contacts";
|
||||
|
||||
"AutoDownloadSettings.StoriesSectionHeader" = "AUTO-DOWNLOAD STORIES";
|
||||
|
@ -939,24 +939,6 @@ private final class DemoSheetContent: CombinedComponent {
|
||||
)
|
||||
)
|
||||
)
|
||||
availableItems[.stories] = DemoPagerComponent.Item(
|
||||
AnyComponentWithIdentity(
|
||||
id: PremiumDemoScreen.Subject.stories,
|
||||
component: AnyComponent(
|
||||
PageComponent(
|
||||
content: AnyComponent(PhoneDemoComponent(
|
||||
context: component.context,
|
||||
position: .top,
|
||||
videoFile: configuration.videos["voice_to_text"],
|
||||
decoration: .badgeStars
|
||||
)),
|
||||
title: strings.Premium_Stories,
|
||||
text: strings.Premium_StoriesInfo,
|
||||
textColor: textColor
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
var items: [DemoPagerComponent.Item] = component.order.compactMap { availableItems[$0] }
|
||||
let index: Int
|
||||
@ -1048,7 +1030,7 @@ private final class DemoSheetContent: CombinedComponent {
|
||||
case .translation:
|
||||
buttonText = strings.Premium_Translation_Proceed
|
||||
case .stories:
|
||||
buttonText = strings.Premium_Stories_Proceed
|
||||
buttonText = strings.Common_OK
|
||||
buttonAnimationName = "premium_unlock"
|
||||
default:
|
||||
buttonText = strings.Common_OK
|
||||
|
@ -395,7 +395,7 @@ enum PremiumPerk: CaseIterable {
|
||||
case .translation:
|
||||
return strings.Premium_Translation
|
||||
case .stories:
|
||||
return strings.Premium_Stories
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,72 @@ final class StoryPrivacyIconComponent: Component {
|
||||
}
|
||||
|
||||
final class View: UIImageView {
|
||||
private let iconView = UIImageView()
|
||||
|
||||
private var component: StoryPrivacyIconComponent?
|
||||
private weak var state: EmptyComponentState?
|
||||
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
self.addSubview(self.iconView)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func update(component: StoryPrivacyIconComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
let previousPrivacy = self.component?.privacy
|
||||
self.component = component
|
||||
self.state = state
|
||||
|
||||
let colors: [CGColor]
|
||||
var icon: UIImage?
|
||||
|
||||
if let previousPrivacy, previousPrivacy != component.privacy {
|
||||
let disappearingBackgroundView = UIImageView(image: self.image)
|
||||
disappearingBackgroundView.frame = self.bounds
|
||||
self.insertSubview(disappearingBackgroundView, at: 0)
|
||||
|
||||
disappearingBackgroundView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak disappearingBackgroundView] _ in
|
||||
disappearingBackgroundView?.removeFromSuperview()
|
||||
})
|
||||
|
||||
let disappearingIconView = UIImageView(image: self.iconView.image)
|
||||
disappearingIconView.frame = self.iconView.frame
|
||||
self.insertSubview(disappearingIconView, belowSubview: self.iconView)
|
||||
|
||||
disappearingIconView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak disappearingIconView] _ in
|
||||
disappearingIconView?.removeFromSuperview()
|
||||
})
|
||||
disappearingIconView.layer.animateScale(from: 1.0, to: 0.01, duration: 0.2, removeOnCompletion: false)
|
||||
|
||||
self.iconView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.iconView.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2)
|
||||
}
|
||||
|
||||
switch component.privacy {
|
||||
case .everyone:
|
||||
colors = [UIColor(rgb: 0x4faaff).cgColor, UIColor(rgb: 0x017aff).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacyEveryone")
|
||||
case .closeFriends:
|
||||
colors = [UIColor(rgb: 0x87d93a).cgColor, UIColor(rgb: 0x31b73b).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacyCloseFriends")
|
||||
case .contacts:
|
||||
colors = [UIColor(rgb: 0xc36eff).cgColor, UIColor(rgb: 0x8c61fa).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacyContacts")
|
||||
case .selectedContacts:
|
||||
colors = [UIColor(rgb: 0xffb643).cgColor, UIColor(rgb: 0xf69a36).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacySelectedContacts")
|
||||
}
|
||||
|
||||
let size = CGSize(width: component.isEditable ? 40.0 : 24.0, height: 24.0)
|
||||
let iconFrame = CGRect(origin: CGPoint(x: component.isEditable ? 1.0 : 0.0, y: 0.0), size: CGSize(width: size.height, height: size.height))
|
||||
self.iconView.image = icon
|
||||
self.iconView.bounds = CGRect(origin: .zero, size: iconFrame.size)
|
||||
self.iconView.center = iconFrame.center
|
||||
|
||||
self.image = generateImage(size, contextGenerator: { size, context in
|
||||
let bounds = CGRect(origin: .zero, size: size)
|
||||
context.clear(bounds)
|
||||
@ -56,32 +114,10 @@ final class StoryPrivacyIconComponent: Component {
|
||||
context.clip()
|
||||
|
||||
var locations: [CGFloat] = [1.0, 0.0]
|
||||
let colors: [CGColor]
|
||||
var icon: UIImage?
|
||||
|
||||
switch component.privacy {
|
||||
case .everyone:
|
||||
colors = [UIColor(rgb: 0x4faaff).cgColor, UIColor(rgb: 0x017aff).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacyEveryone")
|
||||
case .closeFriends:
|
||||
colors = [UIColor(rgb: 0x87d93a).cgColor, UIColor(rgb: 0x31b73b).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacyCloseFriends")
|
||||
case .contacts:
|
||||
colors = [UIColor(rgb: 0xc36eff).cgColor, UIColor(rgb: 0x8c61fa).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacyContacts")
|
||||
case .selectedContacts:
|
||||
colors = [UIColor(rgb: 0xffb643).cgColor, UIColor(rgb: 0xf69a36).cgColor]
|
||||
icon = UIImage(bundleImageName: "Stories/PrivacySelectedContacts")
|
||||
}
|
||||
|
||||
let colorSpace = CGColorSpaceCreateDeviceRGB()
|
||||
let gradient = CGGradient(colorsSpace: colorSpace, colors: colors as CFArray, locations: &locations)!
|
||||
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions())
|
||||
|
||||
if let icon, let cgImage = icon.cgImage {
|
||||
context.draw(cgImage, in: CGRect(origin: CGPoint(x: component.isEditable ? 1.0 : 0.0, y: 0.0), size: icon.size))
|
||||
}
|
||||
|
||||
if component.isEditable {
|
||||
if let arrowIcon = UIImage(bundleImageName: "Stories/PrivacyDownArrow"), let cgImage = arrowIcon.cgImage {
|
||||
context.draw(cgImage, in: CGRect(origin: CGPoint(x: size.width - arrowIcon.size.width - 6.0, y: floorToScreenPixels((size.height - arrowIcon.size.height) / 2.0)), size: arrowIcon.size))
|
||||
|
Loading…
x
Reference in New Issue
Block a user