mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Theme fixes
This commit is contained in:
parent
35e86816f3
commit
735ee8a54b
@ -35,6 +35,7 @@
|
||||
@property (nonatomic, strong) UIImage *knobImage;
|
||||
@property (nonatomic, readonly) UIImageView *knobView;
|
||||
|
||||
@property (nonatomic, assign) bool disableSnapToPositions;
|
||||
@property (nonatomic, assign) NSInteger positionsCount;
|
||||
@property (nonatomic, assign) CGFloat dotSize;
|
||||
|
||||
|
@ -89,7 +89,7 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f;
|
||||
- (void)setPositionsCount:(NSInteger)positionsCount
|
||||
{
|
||||
_positionsCount = positionsCount;
|
||||
_tapGestureRecognizer.enabled = _positionsCount > 1;
|
||||
_tapGestureRecognizer.enabled = !_disableSnapToPositions && _positionsCount > 1;
|
||||
_doubleTapGestureRecognizer.enabled = !_tapGestureRecognizer.enabled;
|
||||
}
|
||||
|
||||
@ -158,7 +158,6 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f;
|
||||
knobFrame = CGRectMake(knobFrame.origin.y, knobFrame.origin.x, knobFrame.size.width, knobFrame.size.height);
|
||||
}
|
||||
|
||||
CGFloat markPosition = visualMargin + visualTotalLength / (_maximumValue - _minimumValue) * (ABS(_minimumValue) + _startValue);
|
||||
if (_markValue > FLT_EPSILON)
|
||||
{
|
||||
CGContextSetFillColorWithColor(context, _backColor.CGColor);
|
||||
@ -174,60 +173,14 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f;
|
||||
|
||||
CGContextSetBlendMode(context, kCGBlendModeCopy);
|
||||
}
|
||||
|
||||
if (false && _minimumUndottedValue > -1 && self.positionsCount > 1) {
|
||||
CGContextSetLineWidth(context, backFrame.size.height);
|
||||
CGContextSetLineCap(context, kCGLineCapRound);
|
||||
|
||||
for (NSInteger i = 1; i < self.positionsCount; i++)
|
||||
{
|
||||
CGFloat previousX = margin + totalLength / (self.positionsCount - 1) * (i - 1);
|
||||
CGFloat currentX = margin + totalLength / (self.positionsCount - 1) * i;
|
||||
|
||||
if (_minimumUndottedValue < i) {
|
||||
CGFloat normalDashWidth = 16.0f;
|
||||
CGFloat dashFraction = 0.6f;
|
||||
CGFloat totalLineWidth = currentX - previousX;
|
||||
int numberOfDashes = (int)floor((double)(totalLineWidth / normalDashWidth));
|
||||
CGFloat dashWidth = (totalLineWidth / (CGFloat)numberOfDashes);
|
||||
|
||||
CGFloat innerWidth = dashWidth * dashFraction - 2.0f;
|
||||
CGFloat innerOffset = (dashWidth - innerWidth) / 2.0f;
|
||||
|
||||
CGFloat dottedX = previousX;
|
||||
|
||||
while (dottedX + innerWidth < currentX) {
|
||||
bool highlighted = dottedX + dashWidth / 2.0f < CGRectGetMaxX(trackFrame);
|
||||
|
||||
CGContextSetStrokeColorWithColor(context, highlighted ? _trackColor.CGColor : _backColor.CGColor);
|
||||
|
||||
CGContextMoveToPoint(context, dottedX + innerOffset, CGRectGetMidY(backFrame));
|
||||
CGContextAddLineToPoint(context, dottedX + innerOffset + innerWidth, CGRectGetMidY(backFrame));
|
||||
CGContextStrokePath(context);
|
||||
|
||||
dottedX += dashWidth;
|
||||
}
|
||||
} else {
|
||||
bool highlighted = (previousX + (currentX - previousX) / 2.0f) < CGRectGetMaxX(trackFrame);
|
||||
CGContextSetStrokeColorWithColor(context, highlighted ? _trackColor.CGColor : _backColor.CGColor);
|
||||
|
||||
CGContextMoveToPoint(context, previousX, CGRectGetMidY(backFrame));
|
||||
CGContextAddLineToPoint(context, currentX, CGRectGetMidY(backFrame));
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CGContextSetFillColorWithColor(context, _backColor.CGColor);
|
||||
[self drawRectangle:backFrame cornerRadius:self.trackCornerRadius context:context];
|
||||
}
|
||||
|
||||
CGContextSetFillColorWithColor(context, _backColor.CGColor);
|
||||
[self drawRectangle:backFrame cornerRadius:self.trackCornerRadius context:context];
|
||||
|
||||
CGContextSetBlendMode(context, kCGBlendModeNormal);
|
||||
|
||||
if (false && _minimumUndottedValue > -1) {
|
||||
} else {
|
||||
CGContextSetFillColorWithColor(context, _trackColor.CGColor);
|
||||
[self drawRectangle:trackFrame cornerRadius:self.trackCornerRadius context:context];
|
||||
}
|
||||
|
||||
CGContextSetFillColorWithColor(context, _trackColor.CGColor);
|
||||
[self drawRectangle:trackFrame cornerRadius:self.trackCornerRadius context:context];
|
||||
|
||||
if (!_startHidden || self.displayEdges)
|
||||
{
|
||||
@ -644,14 +597,14 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f;
|
||||
totalLength -= _knobPadding * 2;
|
||||
|
||||
CGFloat previousValue = self.value;
|
||||
if (self.positionsCount > 1)
|
||||
if (self.positionsCount > 1 && !self.disableSnapToPositions)
|
||||
{
|
||||
NSInteger position = (NSInteger)round((_knobDragCenter / totalLength) * (self.positionsCount - 1));
|
||||
_knobDragCenter = position * totalLength / (self.positionsCount - 1);
|
||||
}
|
||||
|
||||
[self setValue:[self valueForCenterPosition:_knobDragCenter totalLength:totalLength knobSize:_knobView.image.size.width vertical:vertical]];
|
||||
if (previousValue != self.value && (self.positionsCount > 1 || self.value == self.minimumValue || self.value == self.maximumValue || (self.minimumValue != self.startValue && self.value == self.startValue)))
|
||||
if (previousValue != self.value && !self.disableSnapToPositions && (self.positionsCount > 1 || self.value == self.minimumValue || self.value == self.maximumValue || (self.minimumValue != self.startValue && self.value == self.startValue)))
|
||||
{
|
||||
[_feedbackGenerator selectionChanged];
|
||||
[_feedbackGenerator prepare];
|
||||
|
@ -308,7 +308,7 @@ private final class LegacyComponentsGlobalsProviderImpl: NSObject, LegacyCompone
|
||||
let navigationBar = presentationTheme.rootController.navigationBar
|
||||
let tabBar = presentationTheme.rootController.tabBar
|
||||
|
||||
return TGMediaAssetsPallete(dark: presentationTheme.overallDarkAppearance, backgroundColor: theme.plainBackgroundColor, selectionColor: theme.itemHighlightedBackgroundColor, separatorColor: theme.itemPlainSeparatorColor, textColor: theme.itemPrimaryTextColor, secondaryTextColor: theme.controlSecondaryColor, accentColor: theme.itemAccentColor, destructiveColor: theme.itemDestructiveColor, barBackgroundColor: tabBar.backgroundColor, barSeparatorColor: tabBar.separatorColor, navigationTitleColor: navigationBar.primaryTextColor, badge: generateStretchableFilledCircleImage(diameter: 22.0, color: navigationBar.accentTextColor), badgeTextColor: navigationBar.opaqueBackgroundColor, sendIconImage: PresentationResourcesChat.chatInputPanelSendButtonImage(presentationTheme), doneIconImage: PresentationResourcesChat.chatInputPanelApplyButtonImage(presentationTheme), maybeAccentColor: navigationBar.accentTextColor)
|
||||
return TGMediaAssetsPallete(dark: presentationTheme.overallDarkAppearance, backgroundColor: theme.plainBackgroundColor, selectionColor: theme.itemHighlightedBackgroundColor, separatorColor: theme.itemPlainSeparatorColor, textColor: theme.itemPrimaryTextColor, secondaryTextColor: theme.controlSecondaryColor, accentColor: theme.itemAccentColor, destructiveColor: theme.itemDestructiveColor, barBackgroundColor: navigationBar.opaqueBackgroundColor, barSeparatorColor: tabBar.separatorColor, navigationTitleColor: navigationBar.primaryTextColor, badge: generateStretchableFilledCircleImage(diameter: 22.0, color: navigationBar.accentTextColor), badgeTextColor: navigationBar.opaqueBackgroundColor, sendIconImage: PresentationResourcesChat.chatInputPanelSendButtonImage(presentationTheme), doneIconImage: PresentationResourcesChat.chatInputPanelApplyButtonImage(presentationTheme), maybeAccentColor: navigationBar.accentTextColor)
|
||||
}
|
||||
|
||||
func checkButtonPallete() -> TGCheckButtonPallete! {
|
||||
|
@ -183,7 +183,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
private let serviceBackgroundColorPromise = Promise<UIColor>()
|
||||
private var wallpaperDisposable = MetaDisposable()
|
||||
|
||||
private var currentBackgroundColors: ([UInt32], Int32?)?
|
||||
private var currentBackgroundColors: ([UInt32], Int32?, Int32?)?
|
||||
private var currentBackgroundPromise = Promise<(UIColor, UIColor?)?>()
|
||||
|
||||
private var patternWallpaper: TelegramWallpaper?
|
||||
@ -506,11 +506,24 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
|
||||
if !preview {
|
||||
if !backgroundColors.isEmpty {
|
||||
strongSelf.currentBackgroundColors = (backgroundColors, strongSelf.state.rotation)
|
||||
strongSelf.currentBackgroundColors = (backgroundColors, strongSelf.state.rotation, strongSelf.state.patternIntensity)
|
||||
} else {
|
||||
strongSelf.currentBackgroundColors = nil
|
||||
}
|
||||
strongSelf.patternPanelNode.backgroundColors = strongSelf.currentBackgroundColors
|
||||
} else {
|
||||
let previousIntensity = strongSelf.patternPanelNode.backgroundColors?.2
|
||||
let updatedIntensity = strongSelf.state.patternIntensity
|
||||
if let previousIntensity = previousIntensity {
|
||||
if (previousIntensity < 0) != (updatedIntensity < 0) {
|
||||
if !backgroundColors.isEmpty {
|
||||
strongSelf.currentBackgroundColors = (backgroundColors, strongSelf.state.rotation, strongSelf.state.patternIntensity)
|
||||
} else {
|
||||
strongSelf.currentBackgroundColors = nil
|
||||
}
|
||||
strongSelf.patternPanelNode.backgroundColors = strongSelf.currentBackgroundColors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let _ = theme, let (layout, navigationBarHeight, messagesBottomInset) = strongSelf.validLayout {
|
||||
|
@ -315,7 +315,6 @@ public class WallpaperGalleryController: ViewController {
|
||||
self.navigationBar?.updatePresentationData(NavigationBarPresentationData(presentationData: self.presentationData))
|
||||
self.toolbarNode?.updateThemeAndStrings(theme: self.presentationData.theme, strings: self.presentationData.strings)
|
||||
self.patternPanelNode?.updateTheme(self.presentationData.theme)
|
||||
//self.patternPanelNode?.backgroundColors = self.presentationData.theme.overallDarkAppearance ? ([self.presentationData.theme.list.blocksBackgroundColor.rgb], nil) : nil
|
||||
|
||||
self.colorsPanelNode?.updateTheme(self.presentationData.theme)
|
||||
}
|
||||
@ -619,11 +618,11 @@ public class WallpaperGalleryController: ViewController {
|
||||
strongSelf.patternInitialWallpaper = enabled ? initialWallpaper : nil
|
||||
switch initialWallpaper {
|
||||
case let .color(color):
|
||||
strongSelf.patternPanelNode?.backgroundColors = ([color], nil)
|
||||
strongSelf.patternPanelNode?.backgroundColors = ([color], nil, nil)
|
||||
case let .gradient(colors, settings):
|
||||
strongSelf.patternPanelNode?.backgroundColors = (colors, settings.rotation)
|
||||
strongSelf.patternPanelNode?.backgroundColors = (colors, settings.rotation, nil)
|
||||
case let .file(file) where file.isPattern:
|
||||
strongSelf.patternPanelNode?.backgroundColors = (file.settings.colors, file.settings.rotation)
|
||||
strongSelf.patternPanelNode?.backgroundColors = (file.settings.colors, file.settings.rotation, file.settings.intensity)
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -821,13 +820,16 @@ public class WallpaperGalleryController: ViewController {
|
||||
patternPanelNode.patternChanged = { [weak self] pattern, intensity, preview in
|
||||
if let strongSelf = self, strongSelf.validLayout != nil, let patternInitialWallpaper = strongSelf.patternInitialWallpaper {
|
||||
var colors: [UInt32] = []
|
||||
var rotation: Int32?
|
||||
switch patternInitialWallpaper {
|
||||
case let .color(color):
|
||||
colors = [color]
|
||||
case let .file(file):
|
||||
colors = file.settings.colors
|
||||
case let .gradient(colorsValue, _):
|
||||
rotation = file.settings.rotation
|
||||
case let .gradient(colorsValue, settings):
|
||||
colors = colorsValue
|
||||
rotation = settings.rotation
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -841,9 +843,10 @@ public class WallpaperGalleryController: ViewController {
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
strongSelf.patternPanelNode?.backgroundColors = (colors, rotation, intensity)
|
||||
}
|
||||
}
|
||||
patternPanelNode.backgroundColors = self.presentationData.theme.overallDarkAppearance ? ([self.presentationData.theme.list.blocksBackgroundColor.rgb], nil) : nil
|
||||
self.patternPanelNode = patternPanelNode
|
||||
currentPatternPanelNode = patternPanelNode
|
||||
self.overlayNode?.insertSubnode(patternPanelNode, belowSubnode: self.toolbarNode!)
|
||||
|
@ -189,9 +189,22 @@ final class WallpaperPatternPanelNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
var backgroundColors: ([UInt32], Int32?)? = nil {
|
||||
var backgroundColors: ([UInt32], Int32?, Int32?)? = nil {
|
||||
didSet {
|
||||
var updated = false
|
||||
if oldValue?.0 != self.backgroundColors?.0 || oldValue?.1 != self.backgroundColors?.1 {
|
||||
updated = true
|
||||
} else if oldValue?.2 != self.backgroundColors?.2 {
|
||||
if let oldIntensity = oldValue?.2, let newIntensity = self.backgroundColors?.2 {
|
||||
if (oldIntensity < 0) != (newIntensity < 0) {
|
||||
updated = true
|
||||
}
|
||||
} else if (oldValue?.2 != nil) != (self.backgroundColors?.2 != nil) {
|
||||
updated = true
|
||||
}
|
||||
}
|
||||
|
||||
if updated {
|
||||
self.updateWallpapers()
|
||||
}
|
||||
}
|
||||
@ -259,11 +272,14 @@ final class WallpaperPatternPanelNode: ASDisplayNode {
|
||||
self.scrollNode.view.alwaysBounceHorizontal = true
|
||||
|
||||
let sliderView = TGPhotoEditorSliderView()
|
||||
sliderView.disableSnapToPositions = true
|
||||
sliderView.trackCornerRadius = 1.0
|
||||
sliderView.lineSize = 2.0
|
||||
sliderView.minimumValue = 0.0
|
||||
sliderView.startValue = 0.0
|
||||
sliderView.maximumValue = 200.0
|
||||
sliderView.positionsCount = 3
|
||||
sliderView.useLinesForPositions = true
|
||||
sliderView.value = 150.0
|
||||
sliderView.disablesInteractiveTransitionGestureRecognizer = true
|
||||
sliderView.backgroundColor = .clear
|
||||
@ -284,7 +300,14 @@ final class WallpaperPatternPanelNode: ASDisplayNode {
|
||||
node.removeFromSupernode()
|
||||
}
|
||||
|
||||
let backgroundColors = self.backgroundColors ?? ([0xd6e2ee], nil)
|
||||
let backgroundColors = self.backgroundColors ?? ([0xd6e2ee], nil, nil)
|
||||
let intensity: Int32 = backgroundColors.2.flatMap { value in
|
||||
if value < 0 {
|
||||
return -80
|
||||
} else {
|
||||
return 80
|
||||
}
|
||||
} ?? 80
|
||||
|
||||
var selectedFileId: Int64?
|
||||
if let currentWallpaper = self.currentWallpaper, case let .file(file) = currentWallpaper {
|
||||
@ -298,7 +321,7 @@ final class WallpaperPatternPanelNode: ASDisplayNode {
|
||||
|
||||
var updatedWallpaper = wallpaper
|
||||
if case let .file(file) = updatedWallpaper {
|
||||
let settings = WallpaperSettings(colors: backgroundColors.0, intensity: 100, rotation: backgroundColors.1)
|
||||
let settings = WallpaperSettings(colors: backgroundColors.0, intensity: intensity, rotation: backgroundColors.1)
|
||||
updatedWallpaper = .file(id: file.id, accessHash: file.accessHash, isCreator: file.isCreator, isDefault: file.isDefault, isPattern: updatedWallpaper.isPattern, isDark: file.isDark, slug: file.slug, file: file.file, settings: settings)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user