@@ -568,19 +568,33 @@ private final class CameraScreenComponent: CombinedComponent {
568568 }
569569
570570 func toggleCollageCamera( ) {
571- guard let controller = self . getController ( ) , let _ = controller. camera else {
571+ guard let controller = self . getController ( ) , let camera = controller. camera else {
572+ return
573+ }
574+ let currentTimestamp = CACurrentMediaTime ( )
575+ if let lastDualCameraTimestamp = self . lastDualCameraTimestamp, currentTimestamp - lastDualCameraTimestamp < 1.5 {
572576 return
573577 }
578+ if let lastFlipTimestamp = self . lastFlipTimestamp, currentTimestamp - lastFlipTimestamp < 1.0 {
579+ return
580+ }
581+ self . lastDualCameraTimestamp = currentTimestamp
574582
575583 controller. node. dismissAllTooltips ( )
576584
585+ if controller. cameraState. isDualCameraEnabled {
586+ camera. setDualCameraEnabled ( false )
587+ }
588+
577589 if controller. cameraState. isCollageEnabled {
578590 self . displayingCollageSelection = !self . displayingCollageSelection
579591 self . updated ( transition: . spring( duration: 0.3 ) )
580592 } else {
581593 let isEnabled = !controller. cameraState. isCollageEnabled
582594 self . displayingCollageSelection = isEnabled
583- controller. updateCameraState ( { $0. updatedIsCollageEnabled ( isEnabled) . updatedCollageProgress ( 0.0 ) } , transition: . spring( duration: 0.3 ) )
595+ controller. updateCameraState ( {
596+ $0. updatedIsCollageEnabled ( isEnabled) . updatedCollageProgress ( 0.0 ) . updatedIsDualCameraEnabled ( false )
597+ } , transition: . spring( duration: 0.3 ) )
584598 }
585599 self . hapticFeedback. impact ( . light)
586600 }
@@ -635,9 +649,8 @@ private final class CameraScreenComponent: CombinedComponent {
635649 self . displayingCollageSelection = false
636650 self . updated ( transition: . spring( duration: 0.3 ) )
637651
638- //TODO:localize
639652 let presentationData = self . context. sharedContext. currentPresentationData. with { $0 }
640- let tooltipController = UndoOverlayController ( presentationData: presentationData, content: . info( title: nil , text: " Tap a tile to delete or reorder it. " , timeout: 3 .0, customUndoText: nil ) , elevatedLayout: false , action: { _ in
653+ let tooltipController = UndoOverlayController ( presentationData: presentationData, content: . info( title: nil , text: presentationData . strings . Camera_CollageManagementTooltip , timeout: 2 .0, customUndoText: nil ) , elevatedLayout: false , action: { _ in
641654 return true
642655 } )
643656 controller. present ( tooltipController, in: . current)
@@ -1279,68 +1292,66 @@ private final class CameraScreenComponent: CombinedComponent {
12791292 nextButtonX -= dualButton. size. width + 16.0
12801293 }
12811294
1282- if !component. cameraState. isDualCameraEnabled {
1283- let collageButton = collageButton. update (
1284- component: CameraButton (
1285- content: AnyComponentWithIdentity (
1286- id: " collage " ,
1287- component: AnyComponent (
1288- CollageIconComponent (
1289- grid: component. cameraState. collageGrid,
1290- crossed: false ,
1291- isSelected: component. cameraState. isCollageEnabled,
1292- tintColor: controlsTintColor
1293- )
1295+ let collageButton = collageButton. update (
1296+ component: CameraButton (
1297+ content: AnyComponentWithIdentity (
1298+ id: " collage " ,
1299+ component: AnyComponent (
1300+ CollageIconComponent (
1301+ grid: component. cameraState. collageGrid,
1302+ crossed: false ,
1303+ isSelected: component. cameraState. isCollageEnabled,
1304+ tintColor: controlsTintColor
12941305 )
1295- ) ,
1296- action : { [ weak state ] in
1297- if let state {
1298- state. toggleCollageCamera ( )
1299- }
1306+ )
1307+ ) ,
1308+ action : { [ weak state] in
1309+ if let state {
1310+ state . toggleCollageCamera ( )
13001311 }
1301- ) . tagged ( collageButtonTag) ,
1302- availableSize: CGSize ( width: 40.0 , height: 40.0 ) ,
1312+ }
1313+ ) . tagged ( collageButtonTag) ,
1314+ availableSize: CGSize ( width: 40.0 , height: 40.0 ) ,
1315+ transition: . immediate
1316+ )
1317+ var collageButtonX = nextButtonX
1318+ if rightMostButtonWidth. isZero {
1319+ collageButtonX = availableSize. width - topControlInset - collageButton. size. width / 2.0 - 5.0
1320+ }
1321+ context. add ( collageButton
1322+ . position ( CGPoint ( x: collageButtonX, y: max ( environment. statusBarHeight + 5.0 , environment. safeInsets. top + topControlInset) + collageButton. size. height / 2.0 + 2.0 ) )
1323+ . appear ( . default( scale: true ) )
1324+ . disappear ( . default( scale: true ) )
1325+ . shadow ( Shadow ( color: UIColor ( white: 0.0 , alpha: 0.25 ) , radius: 3.0 , offset: . zero) )
1326+ )
1327+ nextButtonX -= collageButton. size. width
1328+
1329+ if state. displayingCollageSelection {
1330+ let collageCarousel = collageCarousel. update (
1331+ component: CollageIconCarouselComponent (
1332+ grids: collageGrids. filter { $0 != component. cameraState. collageGrid } ,
1333+ selected: { [ weak state] grid in
1334+ state? . updateCollageGrid ( grid)
1335+ }
1336+ ) ,
1337+ availableSize: CGSize ( width: nextButtonX + 4.0 , height: 40.0 ) ,
13031338 transition: . immediate
13041339 )
1305- var collageButtonX = nextButtonX
1306- if rightMostButtonWidth. isZero {
1307- collageButtonX = availableSize. width - topControlInset - collageButton. size. width / 2.0 - 5.0
1308- }
1309- context. add ( collageButton
1310- . position ( CGPoint ( x: collageButtonX, y: max ( environment. statusBarHeight + 5.0 , environment. safeInsets. top + topControlInset) + collageButton. size. height / 2.0 + 2.0 ) )
1311- . appear ( . default( scale: true ) )
1312- . disappear ( . default( scale: true ) )
1313- . shadow ( Shadow ( color: UIColor ( white: 0.0 , alpha: 0.25 ) , radius: 3.0 , offset: . zero) )
1340+ context. add ( collageCarousel
1341+ . position ( CGPoint ( x: collageCarousel. size. width / 2.0 , y: max ( environment. statusBarHeight + 5.0 , environment. safeInsets. top + topControlInset) + collageCarousel. size. height / 2.0 + 2.0 ) )
1342+ . appear ( ComponentTransition . Appear ( { _, view, transition in
1343+ if let view = view as? CollageIconCarouselComponent . View , !transition. animation. isImmediate {
1344+ view. animateIn ( )
1345+ }
1346+ } ) )
1347+ . disappear ( ComponentTransition . Disappear ( { view, transition, completion in
1348+ if let view = view as? CollageIconCarouselComponent . View , !transition. animation. isImmediate {
1349+ view. animateOut ( completion: completion)
1350+ } else {
1351+ completion ( )
1352+ }
1353+ } ) )
13141354 )
1315- nextButtonX -= collageButton. size. width
1316-
1317- if state. displayingCollageSelection {
1318- let collageCarousel = collageCarousel. update (
1319- component: CollageIconCarouselComponent (
1320- grids: collageGrids. filter { $0 != component. cameraState. collageGrid } ,
1321- selected: { [ weak state] grid in
1322- state? . updateCollageGrid ( grid)
1323- }
1324- ) ,
1325- availableSize: CGSize ( width: nextButtonX + 4.0 , height: 40.0 ) ,
1326- transition: . immediate
1327- )
1328- context. add ( collageCarousel
1329- . position ( CGPoint ( x: collageCarousel. size. width / 2.0 , y: max ( environment. statusBarHeight + 5.0 , environment. safeInsets. top + topControlInset) + collageCarousel. size. height / 2.0 + 2.0 ) )
1330- . appear ( ComponentTransition . Appear ( { _, view, transition in
1331- if let view = view as? CollageIconCarouselComponent . View , !transition. animation. isImmediate {
1332- view. animateIn ( )
1333- }
1334- } ) )
1335- . disappear ( ComponentTransition . Disappear ( { view, transition, completion in
1336- if let view = view as? CollageIconCarouselComponent . View , !transition. animation. isImmediate {
1337- view. animateOut ( completion: completion)
1338- } else {
1339- completion ( )
1340- }
1341- } ) )
1342- )
1343- }
13441355 }
13451356 }
13461357 }
0 commit comments