Merge commit '5a4a52e7104ac50d82859b8e0cbf09f23cc56aaa'

This commit is contained in:
Ali 2023-10-31 18:20:06 +04:00
commit a7cd45fcb1
8 changed files with 51 additions and 21 deletions

View File

@ -847,10 +847,14 @@ public final class DatePickerNode: ASDisplayNode {
self.updateItems(size: containerSize, transition: transition) self.updateItems(size: containerSize, transition: transition)
self.monthPickerBackgroundNode.frame = CGRect(origin: CGPoint(), size: size) let monthInset: CGFloat = timeHeight + 30.0
self.monthPickerBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: monthInset), size: size)
self.monthPickerBackgroundNode.isUserInteractionEnabled = self.state.displayingMonthSelection self.monthPickerBackgroundNode.isUserInteractionEnabled = self.state.displayingMonthSelection
transition.updateAlpha(node: self.monthPickerBackgroundNode, alpha: self.state.displayingMonthSelection ? 1.0 : 0.0) transition.updateAlpha(node: self.monthPickerBackgroundNode, alpha: self.state.displayingMonthSelection ? 1.0 : 0.0)
transition.updateAlpha(node: self.previousButtonNode, alpha: self.state.displayingMonthSelection ? 0.0 : 1.0)
transition.updateAlpha(node: self.nextButtonNode, alpha: self.state.displayingMonthSelection ? 0.0 : 1.0)
self.timePickerBackgroundNode.frame = CGRect(origin: CGPoint(), size: size) self.timePickerBackgroundNode.frame = CGRect(origin: CGPoint(), size: size)
self.timePickerBackgroundNode.isUserInteractionEnabled = self.state.displayingTimeSelection self.timePickerBackgroundNode.isUserInteractionEnabled = self.state.displayingTimeSelection
transition.updateAlpha(node: self.timePickerBackgroundNode, alpha: self.state.displayingTimeSelection ? 1.0 : 0.0) transition.updateAlpha(node: self.timePickerBackgroundNode, alpha: self.state.displayingTimeSelection ? 1.0 : 0.0)
@ -859,7 +863,7 @@ public final class DatePickerNode: ASDisplayNode {
self.datePickerBackgroundNode.isUserInteractionEnabled = self.state.displayingDateSelection self.datePickerBackgroundNode.isUserInteractionEnabled = self.state.displayingDateSelection
transition.updateAlpha(node: self.datePickerBackgroundNode, alpha: self.state.displayingDateSelection ? 1.0 : 0.0) transition.updateAlpha(node: self.datePickerBackgroundNode, alpha: self.state.displayingDateSelection ? 1.0 : 0.0)
self.monthPickerNode.frame = CGRect(x: sideInset, y: topInset, width: size.width - sideInset * 2.0, height: 180.0) self.monthPickerNode.frame = CGRect(x: sideInset, y: topInset - monthInset, width: size.width - sideInset * 2.0, height: 180.0)
} }
public var toggleDateSelection: () -> Void = {} public var toggleDateSelection: () -> Void = {}

View File

@ -81,7 +81,7 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
case timeHeader(PresentationTheme, String) case timeHeader(PresentationTheme, String)
case timePicker(PresentationTheme, InviteLinkTimeLimit) case timePicker(PresentationTheme, InviteLinkTimeLimit)
case timeExpiryDate(PresentationTheme, PresentationDateTimeFormat, Int32?, Bool) case timeExpiryDate(PresentationTheme, PresentationDateTimeFormat, Int32?, Bool)
case timeCustomPicker(PresentationTheme, PresentationDateTimeFormat, Int32?) case timeCustomPicker(PresentationTheme, PresentationDateTimeFormat, Int32?, Bool, Bool)
case timeInfo(PresentationTheme, String) case timeInfo(PresentationTheme, String)
case usageHeader(PresentationTheme, String) case usageHeader(PresentationTheme, String)
@ -191,8 +191,8 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .timeCustomPicker(lhsTheme, lhsDateTimeFormat, lhsDate): case let .timeCustomPicker(lhsTheme, lhsDateTimeFormat, lhsDate, lhsDisplayingDateSelection, lhsDisplayingTimeSelection):
if case let .timeCustomPicker(rhsTheme, rhsDateTimeFormat, rhsDate) = rhs, lhsTheme === rhsTheme, lhsDateTimeFormat == rhsDateTimeFormat, lhsDate == rhsDate { if case let .timeCustomPicker(rhsTheme, rhsDateTimeFormat, rhsDate, rhsDisplayingDateSelection, rhsDisplayingTimeSelection) = rhs, lhsTheme === rhsTheme, lhsDateTimeFormat == rhsDateTimeFormat, lhsDate == rhsDate, lhsDisplayingDateSelection == rhsDisplayingDateSelection, lhsDisplayingTimeSelection == rhsDisplayingTimeSelection {
return true return true
} else { } else {
return false return false
@ -272,7 +272,8 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
arguments.updateState({ state in arguments.updateState({ state in
var updatedState = state var updatedState = state
if value != updatedState.time { if value != updatedState.time {
updatedState.pickingTimeLimit = false updatedState.pickingExpiryDate = false
updatedState.pickingExpiryTime = false
} }
updatedState.time = value updatedState.time = value
return updatedState return updatedState
@ -289,13 +290,35 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
arguments.dismissInput() arguments.dismissInput()
arguments.updateState { state in arguments.updateState { state in
var updatedState = state var updatedState = state
updatedState.pickingTimeLimit = !state.pickingTimeLimit if updatedState.pickingExpiryTime {
updatedState.pickingExpiryTime = false
} else {
updatedState.pickingExpiryDate = !state.pickingExpiryDate
}
return updatedState return updatedState
} }
}) })
case let .timeCustomPicker(_, dateTimeFormat, date): case let .timeCustomPicker(_, dateTimeFormat, date, displayingDateSelection, displayingTimeSelection):
let title = presentationData.strings.InviteLink_Create_TimeLimitExpiryTime let title = presentationData.strings.InviteLink_Create_TimeLimitExpiryTime
return ItemListDatePickerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, date: date, title: title, displayingDateSelection: false, displayingTimeSelection: false, sectionId: self.section, style: .blocks, toggleDateSelection: {}, toggleTimeSelection: {}, updated: { date in return ItemListDatePickerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, date: date, title: title, displayingDateSelection: displayingDateSelection, displayingTimeSelection: displayingTimeSelection, sectionId: self.section, style: .blocks, toggleDateSelection: {
arguments.updateState({ state in
var updatedState = state
updatedState.pickingExpiryDate = !updatedState.pickingExpiryDate
if updatedState.pickingExpiryDate {
updatedState.pickingExpiryTime = false
}
return updatedState
})
}, toggleTimeSelection: {
arguments.updateState({ state in
var updatedState = state
updatedState.pickingExpiryTime = !updatedState.pickingExpiryTime
if updatedState.pickingExpiryTime {
updatedState.pickingExpiryDate = false
}
return updatedState
})
}, updated: { date in
arguments.updateState({ state in arguments.updateState({ state in
var updatedState = state var updatedState = state
updatedState.time = .custom(date) updatedState.time = .custom(date)
@ -312,7 +335,8 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
arguments.updateState({ state in arguments.updateState({ state in
var updatedState = state var updatedState = state
if value != updatedState.usage { if value != updatedState.usage {
updatedState.pickingTimeLimit = false updatedState.pickingExpiryDate = false
updatedState.pickingExpiryTime = false
} }
updatedState.usage = value updatedState.usage = value
return updatedState return updatedState
@ -341,7 +365,8 @@ private enum InviteLinksEditEntry: ItemListNodeEntry {
if focus { if focus {
arguments.updateState { state in arguments.updateState { state in
var updatedState = state var updatedState = state
updatedState.pickingTimeLimit = false updatedState.pickingExpiryDate = false
updatedState.pickingExpiryTime = false
updatedState.pickingUsageLimit = true updatedState.pickingUsageLimit = true
return updatedState return updatedState
} }
@ -394,9 +419,9 @@ private func inviteLinkEditControllerEntries(invite: ExportedInvitation?, state:
} else if let value = state.time.value { } else if let value = state.time.value {
time = currentTime + value time = currentTime + value
} }
entries.append(.timeExpiryDate(presentationData.theme, presentationData.dateTimeFormat, time, state.pickingTimeLimit)) entries.append(.timeExpiryDate(presentationData.theme, presentationData.dateTimeFormat, time, state.pickingExpiryDate || state.pickingExpiryTime))
if state.pickingTimeLimit { if state.pickingExpiryDate || state.pickingExpiryTime {
entries.append(.timeCustomPicker(presentationData.theme, presentationData.dateTimeFormat, time)) entries.append(.timeCustomPicker(presentationData.theme, presentationData.dateTimeFormat, time, state.pickingExpiryDate, state.pickingExpiryTime))
} }
entries.append(.timeInfo(presentationData.theme, presentationData.strings.InviteLink_Create_TimeLimitInfo)) entries.append(.timeInfo(presentationData.theme, presentationData.strings.InviteLink_Create_TimeLimitInfo))
@ -424,7 +449,8 @@ private struct InviteLinkEditControllerState: Equatable {
var usage: InviteLinkUsageLimit var usage: InviteLinkUsageLimit
var time: InviteLinkTimeLimit var time: InviteLinkTimeLimit
var requestApproval = false var requestApproval = false
var pickingTimeLimit = false var pickingExpiryDate = false
var pickingExpiryTime = false
var pickingUsageLimit = false var pickingUsageLimit = false
var updating = false var updating = false
} }
@ -452,9 +478,9 @@ public func inviteLinkEditController(context: AccountContext, updatedPresentatio
timeLimit = .unlimited timeLimit = .unlimited
} }
initialState = InviteLinkEditControllerState(title: title ?? "", usage: InviteLinkUsageLimit(value: usageLimit), time: timeLimit, requestApproval: requestApproval, pickingTimeLimit: false, pickingUsageLimit: false) initialState = InviteLinkEditControllerState(title: title ?? "", usage: InviteLinkUsageLimit(value: usageLimit), time: timeLimit, requestApproval: requestApproval, pickingExpiryDate: false, pickingExpiryTime: false, pickingUsageLimit: false)
} else { } else {
initialState = InviteLinkEditControllerState(title: "", usage: .unlimited, time: .unlimited, requestApproval: false, pickingTimeLimit: false, pickingUsageLimit: false) initialState = InviteLinkEditControllerState(title: "", usage: .unlimited, time: .unlimited, requestApproval: false, pickingExpiryDate: false, pickingExpiryTime: false, pickingUsageLimit: false)
} }
let statePromise = ValuePromise(initialState, ignoreRepeated: true) let statePromise = ValuePromise(initialState, ignoreRepeated: true)
@ -604,7 +630,7 @@ public func inviteLinkEditController(context: AccountContext, updatedPresentatio
let previousState = previousState.swap(state) let previousState = previousState.swap(state)
var animateChanges = false var animateChanges = false
if let previousState = previousState, previousState.pickingTimeLimit != state.pickingTimeLimit || previousState.requestApproval != state.requestApproval { if let previousState = previousState, previousState.pickingExpiryDate != state.pickingExpiryDate || previousState.pickingExpiryTime != state.pickingExpiryTime || previousState.requestApproval != state.requestApproval {
animateChanges = true animateChanges = true
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -635,7 +635,7 @@ public final class MessageInlineBlockBackgroundView: UIView {
} }
if previousParams?.pattern != params.pattern { if previousParams?.pattern != params.pattern {
if let pattern = params.pattern { if let pattern = params.pattern, pattern.fileId != 0 {
self.layer.masksToBounds = true self.layer.masksToBounds = true
self.layer.cornerRadius = radius self.layer.cornerRadius = radius
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long