Camera and editor improvements

This commit is contained in:
Ilya Laktyushin 2023-05-31 17:07:36 +04:00
parent 6fe6d5b4e7
commit 1ac9959731
6 changed files with 312 additions and 157 deletions

View File

@ -2410,6 +2410,38 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
return nil
}
fileprivate func openStoryCamera() {
var cameraTransitionIn: StoryCameraTransitionIn?
if let componentView = self.chatListHeaderView() {
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
cameraTransitionIn = StoryCameraTransitionIn(
sourceView: transitionView,
sourceRect: transitionView.bounds,
sourceCornerRadius: transitionView.bounds.height * 0.5
)
}
}
if let rootController = self.context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
let coordinator = rootController.openStoryCamera(transitionIn: cameraTransitionIn, transitionedIn: {}, transitionOut: { [weak self] _ in
guard let self else {
return nil
}
if let componentView = self.chatListHeaderView() {
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
return StoryCameraTransitionOut(
destinationView: transitionView,
destinationRect: transitionView.bounds,
destinationCornerRadius: transitionView.bounds.height * 0.5
)
}
}
return nil
})
coordinator?.animateIn()
}
}
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
super.containerLayoutUpdated(layout, transition: transition)
@ -2442,35 +2474,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
if let peer, peer.id == self.context.account.peerId, storyContentState.slice == nil {
var cameraTransitionIn: StoryCameraTransitionIn?
if let componentView = self.chatListHeaderView() {
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
cameraTransitionIn = StoryCameraTransitionIn(
sourceView: transitionView,
sourceRect: transitionView.bounds,
sourceCornerRadius: transitionView.bounds.height * 0.5
)
}
}
if let rootController = self.context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
rootController.openStoryCamera(transitionIn: cameraTransitionIn, transitionedIn: {}, transitionOut: { [weak self] _ in
guard let self else {
return nil
}
if let componentView = self.chatListHeaderView() {
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
return StoryCameraTransitionOut(
destinationView: transitionView,
destinationRect: transitionView.bounds,
destinationCornerRadius: transitionView.bounds.height * 0.5
)
}
}
return nil
})
}
self.openStoryCamera()
return
}
@ -4993,12 +4997,16 @@ private final class ChatListLocationContext {
var leftButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var rightButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var proxyButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var storyButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
var rightButtons: [AnyComponentWithIdentity<NavigationButtonComponentEnvironment>] {
var result: [AnyComponentWithIdentity<NavigationButtonComponentEnvironment>] = []
if let rightButton = self.rightButton {
result.append(rightButton)
}
if let storyButton = self.storyButton {
result.append(storyButton)
}
if let proxyButton = self.proxyButton {
result.append(proxyButton)
}
@ -5455,6 +5463,16 @@ private final class ChatListLocationContext {
self.proxyButton = nil
}
self.storyButton = AnyComponentWithIdentity(id: "story", component: AnyComponent(NavigationButtonComponent(
content: .icon(imageName: "Chat List/AddStoryIcon"),
pressed: { [weak self] _ in
guard let self, let parentController = self.parentController else {
return
}
parentController.openStoryCamera()
}
)))
self.chatListTitle = titleContent
if case .chatList(.root) = self.location, checkProxy {

View File

@ -917,7 +917,7 @@ final class MediaEditorScreenComponent: Component {
settingsButtonView.layer.shadowRadius = 4.0
settingsButtonView.layer.shadowColor = UIColor.black.cgColor
settingsButtonView.layer.shadowOpacity = 0.2
self.addSubview(settingsButtonView)
//self.addSubview(settingsButtonView)
}
transition.setPosition(view: settingsButtonView, position: settingsButtonFrame.center)
transition.setBounds(view: settingsButtonView, bounds: CGRect(origin: .zero, size: settingsButtonFrame.size))

View File

@ -916,72 +916,69 @@ final class ShareWithPeersScreenComponent: Component {
let navigationSideInset: CGFloat = 16.0
var navigationButtonsWidth: CGFloat = 0.0
if case .stories = component.stateContext.subject {
} else {
let navigationLeftButtonSize = self.navigationLeftButton.update(
transition: transition,
component: AnyComponent(Button(
content: AnyComponent(Text(text: "Cancel", font: Font.regular(17.0), color: environment.theme.rootController.navigationBar.accentTextColor)),
action: { [weak self] in
guard let self, let environment = self.environment, let controller = environment.controller() else {
return
}
controller.dismiss()
}
).minSize(CGSize(width: navigationHeight, height: navigationHeight))),
environment: {},
containerSize: CGSize(width: availableSize.width, height: navigationHeight)
)
let navigationLeftButtonFrame = CGRect(origin: CGPoint(x: navigationSideInset, y: floor((navigationHeight - navigationLeftButtonSize.height) * 0.5)), size: navigationLeftButtonSize)
if let navigationLeftButtonView = self.navigationLeftButton.view {
if navigationLeftButtonView.superview == nil {
self.navigationContainerView.addSubview(navigationLeftButtonView)
}
transition.setFrame(view: navigationLeftButtonView, frame: navigationLeftButtonFrame)
}
navigationButtonsWidth += navigationLeftButtonSize.width + navigationSideInset
}
let navigationRightButtonSize = self.navigationRightButton.update(
let navigationLeftButtonSize = self.navigationLeftButton.update(
transition: transition,
component: AnyComponent(Button(
content: AnyComponent(Text(text: "Done", font: Font.semibold(17.0), color: environment.theme.rootController.navigationBar.accentTextColor)),
content: AnyComponent(Text(text: "Cancel", font: Font.regular(17.0), color: environment.theme.rootController.navigationBar.accentTextColor)),
action: { [weak self] in
guard let self, let component = self.component, let controller = self.environment?.controller() else {
guard let self, let environment = self.environment, let controller = environment.controller() else {
return
}
let base: EngineStoryPrivacy.Base
if self.selectedCategories.contains(.everyone) {
base = .everyone
} else if self.selectedCategories.contains(.closeFriends) {
base = .closeFriends
} else if self.selectedCategories.contains(.contacts) {
base = .contacts
} else if self.selectedCategories.contains(.selectedContacts) {
base = .nobody
} else {
base = .nobody
}
component.completion(EngineStoryPrivacy(
base: base,
additionallyIncludePeers: self.selectedPeers
))
controller.dismiss()
}
).minSize(CGSize(width: navigationHeight, height: navigationHeight))),
environment: {},
containerSize: CGSize(width: availableSize.width, height: navigationHeight)
)
let navigationRightButtonFrame = CGRect(origin: CGPoint(x: availableSize.width - navigationSideInset - navigationRightButtonSize.width, y: floor((navigationHeight - navigationRightButtonSize.height) * 0.5)), size: navigationRightButtonSize)
if let navigationRightButtonView = self.navigationRightButton.view {
if navigationRightButtonView.superview == nil {
self.navigationContainerView.addSubview(navigationRightButtonView)
let navigationLeftButtonFrame = CGRect(origin: CGPoint(x: navigationSideInset, y: floor((navigationHeight - navigationLeftButtonSize.height) * 0.5)), size: navigationLeftButtonSize)
if let navigationLeftButtonView = self.navigationLeftButton.view {
if navigationLeftButtonView.superview == nil {
self.navigationContainerView.addSubview(navigationLeftButtonView)
}
transition.setFrame(view: navigationRightButtonView, frame: navigationRightButtonFrame)
transition.setFrame(view: navigationLeftButtonView, frame: navigationLeftButtonFrame)
}
navigationButtonsWidth += navigationRightButtonSize.width + navigationSideInset
navigationButtonsWidth += navigationLeftButtonSize.width + navigationSideInset
// let navigationRightButtonSize = self.navigationRightButton.update(
// transition: transition,
// component: AnyComponent(Button(
// content: AnyComponent(Text(text: "Done", font: Font.semibold(17.0), color: environment.theme.rootController.navigationBar.accentTextColor)),
// action: { [weak self] in
// guard let self, let component = self.component, let controller = self.environment?.controller() else {
// return
// }
//
// let base: EngineStoryPrivacy.Base
// if self.selectedCategories.contains(.everyone) {
// base = .everyone
// } else if self.selectedCategories.contains(.closeFriends) {
// base = .closeFriends
// } else if self.selectedCategories.contains(.contacts) {
// base = .contacts
// } else if self.selectedCategories.contains(.selectedContacts) {
// base = .nobody
// } else {
// base = .nobody
// }
//
// component.completion(EngineStoryPrivacy(
// base: base,
// additionallyIncludePeers: self.selectedPeers
// ))
// controller.dismiss()
// }
// ).minSize(CGSize(width: navigationHeight, height: navigationHeight))),
// environment: {},
// containerSize: CGSize(width: availableSize.width, height: navigationHeight)
// )
// let navigationRightButtonFrame = CGRect(origin: CGPoint(x: availableSize.width - navigationSideInset - navigationRightButtonSize.width, y: floor((navigationHeight - navigationRightButtonSize.height) * 0.5)), size: navigationRightButtonSize)
// if let navigationRightButtonView = self.navigationRightButton.view {
// if navigationRightButtonView.superview == nil {
// self.navigationContainerView.addSubview(navigationRightButtonView)
// }
// transition.setFrame(view: navigationRightButtonView, frame: navigationRightButtonFrame)
// }
// navigationButtonsWidth += navigationRightButtonSize.width + navigationSideInset
let title: String
switch component.stateContext.subject {
@ -1034,7 +1031,7 @@ final class ShareWithPeersScreenComponent: Component {
topInset = 0.0
} else {
if case .stories = component.stateContext.subject {
topInset = max(0.0, availableSize.height - containerInset - 410.0)
topInset = max(0.0, availableSize.height - containerInset - 427.0)
} else {
topInset = max(0.0, availableSize.height - containerInset - 600.0)
}
@ -1045,48 +1042,76 @@ final class ShareWithPeersScreenComponent: Component {
transition.setFrame(layer: self.navigationSeparatorLayer, frame: CGRect(origin: CGPoint(x: 0.0, y: navigationHeight), size: CGSize(width: availableSize.width, height: UIScreenPixel)))
var bottomPanelHeight: CGFloat = 0.0
if case .stories = component.stateContext.subject {
let actionButtonSize = self.actionButton.update(
transition: transition,
component: AnyComponent(Button(
content: AnyComponent(Text(
text: "Send as a Message",
font: Font.regular(17.0),
color: environment.theme.list.itemAccentColor
)),
action: { [weak self] in
guard let self, let component = self.component, let controller = self.environment?.controller() else {
return
}
component.secondaryAction()
controller.dismiss()
let actionButtonTitle: String = "Save Settings"
let actionButtonSize = self.actionButton.update(
transition: transition,
component: AnyComponent(ButtonComponent(
background: ButtonComponent.Background(
color: environment.theme.list.itemCheckColors.fillColor,
foreground: environment.theme.list.itemCheckColors.foregroundColor,
pressedColor: environment.theme.list.itemCheckColors.fillColor.withMultipliedAlpha(0.9)
),
content: AnyComponentWithIdentity(
id: actionButtonTitle,
component: AnyComponent(ButtonTextContentComponent(
text: actionButtonTitle,
badge: 0,
textColor: environment.theme.list.itemCheckColors.foregroundColor,
badgeBackground: environment.theme.list.itemCheckColors.foregroundColor,
badgeForeground: environment.theme.list.itemCheckColors.fillColor
))
),
isEnabled: true,
displaysProgress: false,
action: { [weak self] in
guard let self, let component = self.component, let controller = self.environment?.controller() else {
return
}
).minSize(CGSize(width: 200.0, height: 44.0))),
environment: {},
containerSize: CGSize(width: availableSize.width - navigationSideInset * 2.0, height: 44.0)
)
if environment.inputHeight != 0.0 {
bottomPanelHeight += environment.inputHeight + 8.0 + actionButtonSize.height
} else {
bottomPanelHeight += environment.safeInsets.bottom + actionButtonSize.height
}
let actionButtonFrame = CGRect(origin: CGPoint(x: (availableSize.width - actionButtonSize.width) / 2.0, y: availableSize.height - bottomPanelHeight), size: actionButtonSize)
if let actionButtonView = self.actionButton.view {
if actionButtonView.superview == nil {
self.addSubview(actionButtonView)
let base: EngineStoryPrivacy.Base
if self.selectedCategories.contains(.everyone) {
base = .everyone
} else if self.selectedCategories.contains(.closeFriends) {
base = .closeFriends
} else if self.selectedCategories.contains(.contacts) {
base = .contacts
} else if self.selectedCategories.contains(.selectedContacts) {
base = .nobody
} else {
base = .nobody
}
component.completion(EngineStoryPrivacy(
base: base,
additionallyIncludePeers: self.selectedPeers
))
controller.dismiss()
}
transition.setFrame(view: actionButtonView, frame: actionButtonFrame)
}
)),
environment: {},
containerSize: CGSize(width: availableSize.width - navigationSideInset * 2.0, height: 50.0)
)
transition.setFrame(view: self.bottomBackgroundView, frame: CGRect(origin: CGPoint(x: 0.0, y: availableSize.height - bottomPanelHeight - 8.0), size: CGSize(width: availableSize.width, height: bottomPanelHeight + 8.0)))
self.bottomBackgroundView.update(size: self.bottomBackgroundView.bounds.size, transition: transition.containedViewLayoutTransition)
transition.setFrame(layer: self.bottomSeparatorLayer, frame: CGRect(origin: CGPoint(x: 0.0, y: availableSize.height - bottomPanelHeight - 8.0 - UIScreenPixel), size: CGSize(width: availableSize.width, height: UIScreenPixel)))
var bottomPanelHeight: CGFloat = 0.0
if environment.inputHeight != 0.0 {
bottomPanelHeight += environment.inputHeight + 8.0 + actionButtonSize.height
} else {
bottomPanelHeight += 10.0 + environment.safeInsets.bottom + actionButtonSize.height
}
let actionButtonFrame = CGRect(origin: CGPoint(x: navigationSideInset, y: availableSize.height - bottomPanelHeight), size: actionButtonSize)
if let actionButtonView = self.actionButton.view {
if actionButtonView.superview == nil {
self.addSubview(actionButtonView)
}
transition.setFrame(view: actionButtonView, frame: actionButtonFrame)
}
let itemLayout = ItemLayout(containerSize: availableSize, containerInset: containerInset, bottomInset: bottomPanelHeight + environment.safeInsets.bottom, topInset: topInset, sideInset: sideInset, navigationHeight: navigationHeight, sections: sections)
transition.setFrame(view: self.bottomBackgroundView, frame: CGRect(origin: CGPoint(x: 0.0, y: availableSize.height - bottomPanelHeight - 8.0), size: CGSize(width: availableSize.width, height: bottomPanelHeight + 8.0)))
self.bottomBackgroundView.update(size: self.bottomBackgroundView.bounds.size, transition: transition.containedViewLayoutTransition)
transition.setFrame(layer: self.bottomSeparatorLayer, frame: CGRect(origin: CGPoint(x: 0.0, y: availableSize.height - bottomPanelHeight - 8.0 - UIScreenPixel), size: CGSize(width: availableSize.width, height: UIScreenPixel)))
let itemLayout = ItemLayout(containerSize: availableSize, containerInset: containerInset, bottomInset: bottomPanelHeight, topInset: topInset, sideInset: sideInset, navigationHeight: navigationHeight, sections: sections)
let previousItemLayout = self.itemLayout
self.itemLayout = itemLayout

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "ic_newstory.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,136 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 5.334961 5.334961 cm
0.000000 0.000000 0.000000 scn
9.449870 17.997356 m
9.521360 17.999166 9.593074 18.000078 9.665000 18.000078 c
10.034567 18.000078 10.398193 17.976067 10.754469 17.929594 c
11.118653 17.882090 11.452393 18.138809 11.499898 18.502993 c
11.547402 18.867176 11.290683 19.200916 10.926498 19.248421 c
10.513331 19.302315 10.092241 19.330078 9.665000 19.330078 c
7.079488 19.330078 4.731096 18.314842 2.996726 16.661268 c
2.869770 16.540228 2.746105 16.415766 2.625877 16.288031 c
0.997681 14.558178 0.000000 12.228138 0.000000 9.665078 c
0.000000 7.162970 0.950794 4.882930 2.510792 3.166550 c
2.803406 2.844603 3.117454 2.542486 3.450681 2.262457 c
5.042018 0.925171 7.070760 0.091568 9.291392 0.007164 c
9.415345 0.002453 9.539894 0.000076 9.665000 0.000076 c
10.092241 0.000076 10.513330 0.027840 10.926498 0.081734 c
11.290683 0.129238 11.547402 0.462978 11.499897 0.827162 c
11.452393 1.191347 11.118653 1.448067 10.754469 1.400562 c
10.398193 1.354088 10.034567 1.330078 9.665000 1.330078 c
9.530147 1.330078 9.396041 1.333281 9.262755 1.339613 c
7.263335 1.434616 5.448418 2.234112 4.060734 3.495360 c
3.838658 3.697204 3.627523 3.910872 3.428325 4.135371 c
2.167055 5.556847 1.384340 7.412554 1.332722 9.449948 c
1.330911 9.521439 1.330000 9.593152 1.330000 9.665078 c
1.330000 9.757984 1.331520 9.850536 1.334537 9.942709 c
1.403918 12.062651 2.264948 13.982349 3.631555 15.415731 c
3.736506 15.525810 3.844438 15.633020 3.955222 15.737234 c
5.398290 17.094700 7.325295 17.943529 9.449870 17.997356 c
h
15.549259 17.332964 m
15.258044 17.556751 14.840552 17.502090 14.616766 17.210875 c
14.392979 16.919661 14.447639 16.502169 14.738854 16.278381 c
15.316504 15.834481 15.834403 15.316582 16.278303 14.738933 c
16.502090 14.447718 16.919582 14.393057 17.210798 14.616844 c
17.502012 14.840631 17.556675 15.258122 17.332888 15.549337 c
16.818552 16.218645 16.218567 16.818628 15.549259 17.332964 c
h
19.248344 10.926577 m
19.200840 11.290761 18.867100 11.547480 18.502916 11.499975 c
18.138731 11.452471 17.882011 11.118731 17.929516 10.754547 c
17.975990 10.398272 18.000000 10.034645 18.000000 9.665078 c
18.000000 9.295511 17.975990 8.931885 17.929516 8.575609 c
17.882011 8.211425 18.138731 7.877686 18.502914 7.830180 c
18.867100 7.782676 19.200840 8.039395 19.248344 8.403580 c
19.302238 8.816747 19.330002 9.237837 19.330002 9.665078 c
19.330002 10.092319 19.302238 10.513409 19.248344 10.926577 c
h
17.332888 3.780819 m
17.556675 4.072034 17.502012 4.489526 17.210798 4.713312 c
16.919582 4.937099 16.502090 4.882439 16.278303 4.591224 c
15.834403 4.013574 15.316504 3.495675 14.738854 3.051775 c
14.447639 2.827988 14.392979 2.410496 14.616766 2.119280 c
14.840552 1.828066 15.258044 1.773403 15.549259 1.997190 c
16.218567 2.511526 16.818552 3.111511 17.332888 3.780819 c
h
9.665000 14.330078 m
10.032269 14.330078 10.330000 14.032348 10.330000 13.665078 c
10.330000 10.330078 l
13.665000 10.330078 l
14.032269 10.330078 14.330000 10.032348 14.330000 9.665078 c
14.330000 9.297809 14.032269 9.000078 13.665000 9.000078 c
10.330000 9.000078 l
10.330000 5.665078 l
10.330000 5.297809 10.032269 5.000078 9.665000 5.000078 c
9.297730 5.000078 9.000000 5.297809 9.000000 5.665078 c
9.000000 9.000078 l
5.665000 9.000078 l
5.297730 9.000078 5.000000 9.297809 5.000000 9.665078 c
5.000000 10.032348 5.297730 10.330078 5.665000 10.330078 c
9.000000 10.330078 l
9.000000 13.665078 l
9.000000 14.032348 9.297730 14.330078 9.665000 14.330078 c
h
f*
n
Q
endstream
endobj
3 0 obj
3544
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 30.000000 30.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000003634 00000 n
0000003657 00000 n
0000003830 00000 n
0000003904 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
3963
%%EOF

View File

@ -191,42 +191,6 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
accountSettingsController.parentController = self
controllers.append(accountSettingsController)
// tabBarController.cameraItemAndAction = (
// UITabBarItem(title: "Camera", image: UIImage(bundleImageName: "Chat List/Tabs/IconCamera"), tag: 2),
// { [weak self] in
// guard let self else {
// return
// }
// let coordinator = self.openStoryCamera(
// transitionIn: nil,
// transitionedIn: { [weak self] in
// guard let self, let rootTabController = self.rootTabController else {
// return
// }
// if let index = rootTabController.controllers.firstIndex(where: { $0 is ChatListController}) {
// rootTabController.selectedIndex = index
// }
// },
// transitionOut: { [weak self] finished in
// guard let self else {
// return nil
// }
// if finished {
// if let chatListController = self.chatListController as? ChatListControllerImpl, let transitionView = chatListController.transitionViewForOwnStoryItem() {
// return StoryCameraTransitionOut(
// destinationView: transitionView,
// destinationRect: transitionView.bounds,
// destinationCornerRadius: transitionView.bounds.height / 2.0
// )
// }
// }
// return nil
// }
// )
// coordinator?.animateIn()
// }
// )
tabBarController.setControllers(controllers, selectedIndex: restoreSettignsController != nil ? (controllers.count - 1) : (controllers.count - 2))
self.contactsController = contactsController