From aa9c8099893d63f272a78e7ae65e071d2b88b752 Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Thu, 13 Jul 2023 12:16:19 +0200 Subject: [PATCH 01/14] CATTY-717 Allow selection of images from files Setup Segmented Controll --- src/Catty.xcodeproj/project.pbxproj | 4 + .../ObjectTableViewControllerExtension.swift | 34 ++++++ src/Catty/Storyboard+XIB/iPhone.storyboard | 104 +++++++----------- .../Supporting Files/Catty-Bridging-Header.h | 1 + .../ObjectTableViewController.h | 1 + .../ObjectTableViewController.m | 5 +- 6 files changed, 84 insertions(+), 65 deletions(-) create mode 100644 src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift diff --git a/src/Catty.xcodeproj/project.pbxproj b/src/Catty.xcodeproj/project.pbxproj index a55b5f5c55..e0d53a2b7b 100644 --- a/src/Catty.xcodeproj/project.pbxproj +++ b/src/Catty.xcodeproj/project.pbxproj @@ -1751,6 +1751,7 @@ AAF6D9DE1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DD1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift */; }; AAF6D9E01BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */; }; AAF6D9E21BC0C48300686849 /* PointToBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */; }; + B068304E2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B068304D2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift */; }; BA1FA9981F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA9971F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m */; }; BA1FA99D1F02AEDC0084184D /* InsertItemIntoUserListBrick.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99C1F02AEDC0084184D /* InsertItemIntoUserListBrick.m */; }; BA1FA9A01F02B0020084184D /* InsertItemIntoUserListBrickCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99F1F02B0020084184D /* InsertItemIntoUserListBrickCell.m */; }; @@ -4395,6 +4396,7 @@ AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointInDirectionBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointInDirectionBrick+Instruction.swift"; sourceTree = ""; }; AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointToBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointToBrick+Instruction.swift"; sourceTree = ""; }; ABD74577198FBC2984BDDE56 /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = ""; }; + B068304D2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ObjectTableViewControllerExtension.swift; path = "Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift"; sourceTree = SOURCE_ROOT; }; B11EA657D0D5E2E348790671 /* ta */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ta; path = ta.lproj/Localizable.strings; sourceTree = ""; }; B46B270517703F9400172837 /* CattyTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CattyTests-Info.plist"; sourceTree = ""; }; B46B270717703F9400172837 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -8038,6 +8040,7 @@ 59F007C2253081FD00039EBD /* UIViewController */ = { isa = PBXGroup; children = ( + B068304D2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift */, 594DF6E825EA9160005CEE16 /* ProjectDetailStoreViewControllerDownloadExtension.swift */, 5E18A81121A547AA00541536 /* UIViewControllerExtension.swift */, 05A3CE6A24F516490051DB39 /* CatrobatTableViewControllerExtension.swift */, @@ -13516,6 +13519,7 @@ 92FF32B21A24E2F400093DA7 /* RoundBorderedButton.m in Sources */, 498C158228070C6C00B81C8E /* LeftAnkleYSensor.swift in Sources */, 229DC44A25D698FF00BA9AA2 /* StoreProjectDownloaderError.swift in Sources */, + B068304E2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift in Sources */, 4CA50301268C8E0E00B331EC /* DeviceDoubleSensor.swift in Sources */, 92EC985C1BC3ABB90003A891 /* PhiroMotorMoveBackwardBrick+CBXMLHandler.m in Sources */, 4C0F9F4F204BD0B400E71B2D /* CameraPreviewHandler.m in Sources */, diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift new file mode 100644 index 0000000000..0a45ae3960 --- /dev/null +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2010-2023 The Catrobat Team + * (http://developer.catrobat.org/credits) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * An additional term exception under section 7 of the GNU Affero + * General Public License, version 3, is available at + * (http://developer.catrobat.org/license_additional_term) + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +import Foundation + +@objc extension ObjectTableViewController { + func configureSegmentedControll() { + + self.objectSegmentedControl.setTitle(kLocalizedMostDownloaded, forSegmentAt: 0) + self.objectSegmentedControl.setTitle(kLocalizedMostViewed, forSegmentAt: 1) + self.objectSegmentedControl.setTitle(kLocalizedNewest, forSegmentAt: 2) + print("Here") + + } +} diff --git a/src/Catty/Storyboard+XIB/iPhone.storyboard b/src/Catty/Storyboard+XIB/iPhone.storyboard index 9a24cd1e38..05ffaebbf1 100644 --- a/src/Catty/Storyboard+XIB/iPhone.storyboard +++ b/src/Catty/Storyboard+XIB/iPhone.storyboard @@ -209,76 +209,54 @@ - + - + - - + + - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1993,7 +1971,7 @@ - + @@ -2166,8 +2144,8 @@ - - + + diff --git a/src/Catty/Supporting Files/Catty-Bridging-Header.h b/src/Catty/Supporting Files/Catty-Bridging-Header.h index 9aab3cc51a..4908856feb 100644 --- a/src/Catty/Supporting Files/Catty-Bridging-Header.h +++ b/src/Catty/Supporting Files/Catty-Bridging-Header.h @@ -173,6 +173,7 @@ #import "CatrobatTableViewController.h" #import "ScriptCollectionViewController.h" #import "ProjectDetailStoreViewController.h" +#import "ObjectTableViewController.h" //------------------------------------------------------------------------------------------------------------ diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h index d93e096cab..b5528d494f 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h @@ -26,5 +26,6 @@ @class SpriteObject; @interface ObjectTableViewController : BaseTableViewController +@property (strong, nonatomic) IBOutlet UISegmentedControl *objectSegmentedControl; @property (strong, nonatomic) SpriteObject *object; @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m index becb719e72..8f0491bad0 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m @@ -41,8 +41,9 @@ - (void)viewDidLoad [super viewDidLoad]; self.title = self.object.name; self.navigationItem.title = self.object.name; - [self setupToolBar]; - self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; + //[self setupToolBar]; + [self configureSegmentedControll]; + //self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; } - (void)didReceiveMemoryWarning From 675c03465544f34d6cf70a8b77240f560e499286 Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Thu, 13 Jul 2023 13:16:36 +0200 Subject: [PATCH 02/14] CATTY-710 Turn object overview from list to segments Passing the Sprite Object to the new Object View controller now works --- src/Catty.xcodeproj/project.pbxproj | 4 ++ .../ObjectSwiftTableViewController.swift | 57 +++++++++++++++++++ src/Catty/Storyboard+XIB/iPhone.storyboard | 8 ++- .../Continue&New/SceneTableViewController.m | 7 ++- 4 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift diff --git a/src/Catty.xcodeproj/project.pbxproj b/src/Catty.xcodeproj/project.pbxproj index e0d53a2b7b..4fbad357af 100644 --- a/src/Catty.xcodeproj/project.pbxproj +++ b/src/Catty.xcodeproj/project.pbxproj @@ -1752,6 +1752,7 @@ AAF6D9E01BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */; }; AAF6D9E21BC0C48300686849 /* PointToBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */; }; B068304E2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B068304D2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift */; }; + B06830562A6007DC00BF06BD /* ObjectSwiftTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B06830552A6007DC00BF06BD /* ObjectSwiftTableViewController.swift */; }; BA1FA9981F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA9971F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m */; }; BA1FA99D1F02AEDC0084184D /* InsertItemIntoUserListBrick.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99C1F02AEDC0084184D /* InsertItemIntoUserListBrick.m */; }; BA1FA9A01F02B0020084184D /* InsertItemIntoUserListBrickCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99F1F02B0020084184D /* InsertItemIntoUserListBrickCell.m */; }; @@ -4397,6 +4398,7 @@ AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointToBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointToBrick+Instruction.swift"; sourceTree = ""; }; ABD74577198FBC2984BDDE56 /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = ""; }; B068304D2A5FF66600BF06BD /* ObjectTableViewControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ObjectTableViewControllerExtension.swift; path = "Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift"; sourceTree = SOURCE_ROOT; }; + B06830552A6007DC00BF06BD /* ObjectSwiftTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectSwiftTableViewController.swift; sourceTree = ""; }; B11EA657D0D5E2E348790671 /* ta */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ta; path = ta.lproj/Localizable.strings; sourceTree = ""; }; B46B270517703F9400172837 /* CattyTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CattyTests-Info.plist"; sourceTree = ""; }; B46B270717703F9400172837 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -8045,6 +8047,7 @@ 5E18A81121A547AA00541536 /* UIViewControllerExtension.swift */, 05A3CE6A24F516490051DB39 /* CatrobatTableViewControllerExtension.swift */, 4926233B27AA8A2800866183 /* SceneTableViewControllerExtension.swift */, + B06830552A6007DC00BF06BD /* ObjectSwiftTableViewController.swift */, ); path = UIViewController; sourceTree = ""; @@ -12889,6 +12892,7 @@ AA401FE91BBEF6F9001BC49F /* CBInstructionProtocol.swift in Sources */, AABCB3E21BB36529009F67D2 /* CBScheduler.swift in Sources */, BACDF3521F1F9B7E00346167 /* DeleteItemOfUserListBrick.m in Sources */, + B06830562A6007DC00BF06BD /* ObjectSwiftTableViewController.swift in Sources */, BB9EC0E527D62CBA009FF8CE /* FormTableViewCell.swift in Sources */, 4614B1DD25608E8B004174AD /* StitchBrickCell.swift in Sources */, AABCB3DF1BB3650B009F67D2 /* CBBackendProtocol.swift in Sources */, diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift new file mode 100644 index 0000000000..a5e0199c93 --- /dev/null +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2010-2023 The Catrobat Team + * (http://developer.catrobat.org/credits) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * An additional term exception under section 7 of the GNU Affero + * General Public License, version 3, is available at + * (http://developer.catrobat.org/license_additional_term) + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +import UIKit + +class ObjectSwiftTableViewController: UIViewController { + + @IBOutlet private weak var objectSegmentedControl: UISegmentedControl! + + public var object: SpriteObject? + + var SoundViewController = SoundsTableViewController() + var LooksViewController = LooksTableViewController() + var ScriptsViewController = ScriptCollectionViewController() + + override func viewDidLoad() { + super.viewDidLoad() + configureSegmentedControll() + + if let object = object { + self.title = object.name + self.navigationItem.title = object.name + } + + } + + func configureSegmentedControll() { + + self.objectSegmentedControl.setTitle(kLocalizedScripts, forSegmentAt: 0) + self.objectSegmentedControl.setTitle(kLocalizedBackgrounds, forSegmentAt: 1) + self.objectSegmentedControl.setTitle(kLocalizedSounds, forSegmentAt: 2) + } + + @objc func setObject(_ object: SpriteObject) { + self.object = object + } + +} diff --git a/src/Catty/Storyboard+XIB/iPhone.storyboard b/src/Catty/Storyboard+XIB/iPhone.storyboard index 05ffaebbf1..dc29b75f04 100644 --- a/src/Catty/Storyboard+XIB/iPhone.storyboard +++ b/src/Catty/Storyboard+XIB/iPhone.storyboard @@ -217,10 +217,10 @@ - + - + @@ -234,6 +234,7 @@ + @@ -253,6 +254,9 @@ + + + diff --git a/src/Catty/ViewController/Continue&New/SceneTableViewController.m b/src/Catty/ViewController/Continue&New/SceneTableViewController.m index 692d20c111..acd09281f0 100644 --- a/src/Catty/ViewController/Continue&New/SceneTableViewController.m +++ b/src/Catty/ViewController/Continue&New/SceneTableViewController.m @@ -632,10 +632,13 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender UITableViewCell *cell = (UITableViewCell*) sender; NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; if ([segue.identifier isEqualToString:toObjectSegueID]) { - if ([destController isKindOfClass:[ObjectTableViewController class]]) { - ObjectTableViewController *tvc = (ObjectTableViewController*) destController; + if ([destController isKindOfClass:[ObjectSwiftTableViewController class]]) { + ObjectSwiftTableViewController *tvc = (ObjectSwiftTableViewController*) destController; + if ([tvc respondsToSelector:@selector(setObject:)]) { SpriteObject* object = [self.scene.objects objectAtIndex:(kBackgroundObjectIndex + indexPath.section + indexPath.row)]; + //tvc.title = object.name; + //tvc.navigationItem.title = object.name; [destController performSelector:@selector(setObject:) withObject:object]; } } From a89054cf1b0484b099758954a600d8e2156a05e1 Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Thu, 13 Jul 2023 22:40:17 +0200 Subject: [PATCH 03/14] CATTY-710 Turn object overview from list to segments Basic Implementation of Catty 710. However the backgrounds still causing issues and there are still some bugs to resolve. --- .../ObjectSwiftTableViewController.swift | 72 ++++++++++++++++++- .../ObjectTableViewControllerExtension.swift | 6 +- src/Catty/Storyboard+XIB/iPhone.storyboard | 50 +++++++------ .../ScriptCollectionViewController.h | 2 + .../ScriptCollectionViewController.m | 1 + .../SoundsTableViewController.h | 3 + .../ObjectTableViewController.h | 3 +- .../ObjectTableViewController.m | 2 +- 8 files changed, 108 insertions(+), 31 deletions(-) diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift index a5e0199c93..ca6642b07b 100644 --- a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift @@ -26,11 +26,12 @@ class ObjectSwiftTableViewController: UIViewController { @IBOutlet private weak var objectSegmentedControl: UISegmentedControl! + @IBOutlet private weak var scriptsContainerView: UIView! public var object: SpriteObject? - var SoundViewController = SoundsTableViewController() - var LooksViewController = LooksTableViewController() - var ScriptsViewController = ScriptCollectionViewController() + var soundViewController = SoundsTableViewController() + //var looksViewController = LooksTableViewController() + var scriptsViewController = ScriptCollectionViewController(collectionViewLayout: type(of: UICollectionViewFlowLayout()).init()) override func viewDidLoad() { super.viewDidLoad() @@ -40,7 +41,34 @@ class ObjectSwiftTableViewController: UIViewController { self.title = object.name self.navigationItem.title = object.name } + navigationController?.setToolbarHidden(false, animated: true) + configureViewControllers() + setupToolBar() + } + + func configureViewControllers() { + + scriptsContainerView.addSubview(scriptsViewController.view) + //scriptsContainerView.addSubview(looksViewController.view) + scriptsContainerView.addSubview(soundViewController.view) + //scriptsViewController.didMove(toParent: self) + scriptsViewController.view.frame = scriptsContainerView.bounds + + //soundViewController.didMove(toParent: self) + soundViewController.view.frame = scriptsContainerView.bounds +// looksViewController.didMove(toParent: self) +// looksViewController.view.frame = scriptsContainerView.bounds + + soundViewController.object = object + //looksViewController.object = object + scriptsViewController.object = object + + scriptsViewController.view.isHidden = false + //looksViewController.view.isHidden = true + soundViewController.view.isHidden = true + + //looksViewController.setupToolBar() } func configureSegmentedControll() { @@ -50,8 +78,46 @@ class ObjectSwiftTableViewController: UIViewController { self.objectSegmentedControl.setTitle(kLocalizedSounds, forSegmentAt: 2) } + @IBAction private func segmentTapped(_ sender: UISegmentedControl) { + + switch sender.selectedSegmentIndex { + case 0: + //scriptsViewController.setEditing(true, animated: true) + scriptsViewController.view.isHidden = false + //looksViewController.view.isHidden = true + soundViewController.view.isHidden = true + setupToolBar() + case 1: + scriptsViewController.view.isHidden = true + //looksViewController.view.isHidden = false + soundViewController.view.isHidden = true + case 2: + scriptsViewController.view.isHidden = true + //looksViewController.view.isHidden = true + soundViewController.view.isHidden = false + setupToolBarForSound() + default: + break + } + + } @objc func setObject(_ object: SpriteObject) { self.object = object } + func setupToolBar() { + + let add = UIBarButtonItem(barButtonSystemItem: .add, target: scriptsViewController, action: #selector(ScriptCollectionViewController.showBrickPickerAction)) + let play = PlayButton(target: scriptsViewController, action: #selector(ScriptCollectionViewController.playSceneAction(_:))) + let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) + self.toolbarItems = [flex, add, flex, flex, play, flex] + } + + func setupToolBarForSound() { + + let add = UIBarButtonItem(barButtonSystemItem: .add, target: soundViewController, action: #selector(soundViewController.addSoundAction(_:))) + let play = PlayButton(target: soundViewController, action: #selector(soundViewController.playSceneAction(_:))) + let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) + self.toolbarItems = [flex, add, flex, flex, play, flex] + } } diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift index 0a45ae3960..cbbcab4727 100644 --- a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectTableViewControllerExtension.swift @@ -25,9 +25,9 @@ import Foundation @objc extension ObjectTableViewController { func configureSegmentedControll() { - self.objectSegmentedControl.setTitle(kLocalizedMostDownloaded, forSegmentAt: 0) - self.objectSegmentedControl.setTitle(kLocalizedMostViewed, forSegmentAt: 1) - self.objectSegmentedControl.setTitle(kLocalizedNewest, forSegmentAt: 2) + self.objectSegementedControl.setTitle(kLocalizedMostDownloaded, forSegmentAt: 0) + self.objectSegementedControl.setTitle(kLocalizedMostViewed, forSegmentAt: 1) + self.objectSegementedControl.setTitle(kLocalizedNewest, forSegmentAt: 2) print("Here") } diff --git a/src/Catty/Storyboard+XIB/iPhone.storyboard b/src/Catty/Storyboard+XIB/iPhone.storyboard index dc29b75f04..80bd1c8d38 100644 --- a/src/Catty/Storyboard+XIB/iPhone.storyboard +++ b/src/Catty/Storyboard+XIB/iPhone.storyboard @@ -236,31 +236,34 @@ + + + - - - - + + + - - + - - + + + - + + - + @@ -302,15 +305,15 @@ - + - + - + - + @@ -374,7 +377,7 @@ diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h index 95ed4b6fe1..172bf23fad 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h @@ -29,6 +29,8 @@ @property (nonatomic, strong) SpriteObject *object; - (void)removeBrickOrScript:(id)scriptOrBrick atIndexPath:(NSIndexPath*)indexPath; +-(void)turnOnInsertingBrickMode; +- (void)showBrickPickerAction:(id)sender; @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m index f45a73fc22..358aa4264f 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m @@ -789,6 +789,7 @@ -(void)deleteSelectedBricks -(void)turnOnInsertingBrickMode { + NSLog(@"@%ss","turn on"); [[BrickInsertManager sharedInstance] setBrickInsertionMode:YES]; for (UIButton *button in self.navigationController.toolbar.items) { button.enabled = NO; diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h index 463d3465e0..2ec6f8544a 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h @@ -36,5 +36,8 @@ @property (strong, nonatomic) SpriteObject *object; @property (nonatomic) BOOL showAddSoundActionSheetAtStart; @property (copy) void (^afterSafeBlock)(Sound* look); +- (void)playSceneAction:(id)sender; +- (void)addSoundAction:(id)sender; + @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h index b5528d494f..1c46d56160 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h @@ -26,6 +26,7 @@ @class SpriteObject; @interface ObjectTableViewController : BaseTableViewController -@property (strong, nonatomic) IBOutlet UISegmentedControl *objectSegmentedControl; +@property (weak, nonatomic) IBOutlet UISegmentedControl *objectSegementedControl; + @property (strong, nonatomic) SpriteObject *object; @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m index 8f0491bad0..3131b50c1a 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m @@ -41,7 +41,7 @@ - (void)viewDidLoad [super viewDidLoad]; self.title = self.object.name; self.navigationItem.title = self.object.name; - //[self setupToolBar]; + [self setupToolBar]; [self configureSegmentedControll]; //self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; } From d9e09d1f2aed015364949d1b73abc6c00696164d Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Sun, 16 Jul 2023 11:31:17 +0200 Subject: [PATCH 04/14] CATTY-710 Turn object overview from list to segments Added Play Button Action for Scripts and fixed issue where the label add scripts was shown although there were already scripts --- .../ObjectSwiftTableViewController.swift | 66 ++++++++++++++----- .../BaseCollectionViewController.h | 1 + .../BaseCollectionViewController.m | 1 - ...nterViewControllerResourcesExtension.swift | 2 +- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift index ca6642b07b..82e00e082b 100644 --- a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift @@ -43,10 +43,12 @@ class ObjectSwiftTableViewController: UIViewController { } navigationController?.setToolbarHidden(false, animated: true) configureViewControllers() - setupToolBar() + setupToolBarForScripts() } func configureViewControllers() { + scriptsViewController.object = object + soundViewController.object = object scriptsContainerView.addSubview(scriptsViewController.view) //scriptsContainerView.addSubview(looksViewController.view) @@ -60,9 +62,8 @@ class ObjectSwiftTableViewController: UIViewController { // looksViewController.didMove(toParent: self) // looksViewController.view.frame = scriptsContainerView.bounds - soundViewController.object = object + //looksViewController.object = object - scriptsViewController.object = object scriptsViewController.view.isHidden = false //looksViewController.view.isHidden = true @@ -82,20 +83,13 @@ class ObjectSwiftTableViewController: UIViewController { switch sender.selectedSegmentIndex { case 0: - //scriptsViewController.setEditing(true, animated: true) - scriptsViewController.view.isHidden = false - //looksViewController.view.isHidden = true - soundViewController.view.isHidden = true - setupToolBar() + showScripts() case 1: scriptsViewController.view.isHidden = true //looksViewController.view.isHidden = false soundViewController.view.isHidden = true case 2: - scriptsViewController.view.isHidden = true - //looksViewController.view.isHidden = true - soundViewController.view.isHidden = false - setupToolBarForSound() + showSounds() default: break } @@ -105,19 +99,57 @@ class ObjectSwiftTableViewController: UIViewController { self.object = object } - func setupToolBar() { + func showScripts() { + scriptsViewController.view.isHidden = false + //looksViewController.view.isHidden = true + soundViewController.view.isHidden = true + setupToolBarForScripts() + } - let add = UIBarButtonItem(barButtonSystemItem: .add, target: scriptsViewController, action: #selector(ScriptCollectionViewController.showBrickPickerAction)) - let play = PlayButton(target: scriptsViewController, action: #selector(ScriptCollectionViewController.playSceneAction(_:))) + func showSounds() { + scriptsViewController.view.isHidden = true + //looksViewController.view.isHidden = true + soundViewController.view.isHidden = false + setupToolBarForSound() + } + + func setupToolBarForScripts() { + let add = UIBarButtonItem(barButtonSystemItem: .add, target: scriptsViewController, action: #selector(scriptsViewController.showBrickPickerAction)) + let play = PlayButton(target: self, action: #selector(scriptPlayButtonPressed)) let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) self.toolbarItems = [flex, add, flex, flex, play, flex] } - - func setupToolBarForSound() { + func setupToolBarForSound() { let add = UIBarButtonItem(barButtonSystemItem: .add, target: soundViewController, action: #selector(soundViewController.addSoundAction(_:))) let play = PlayButton(target: soundViewController, action: #selector(soundViewController.playSceneAction(_:))) let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) self.toolbarItems = [flex, add, flex, flex, play, flex] } + + @objc func scriptPlayButtonPressed() { + playSceneAction(UIBarButtonItem()) + } + + func playSceneAction(_ sender: Any) { + scriptsViewController.showLoadingView() + + (UIApplication.shared.delegate as? AppDelegate)?.enabledOrientation = true + let lastProjectQueue = DispatchQueue(label: "lastProjectQueue") + lastProjectQueue.async { + let landscapeMode = Project.lastUsed().header.landscapeMode + DispatchQueue.main.async { [self] in + if !landscapeMode { + UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation") + } else { + UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation") + } + + scriptsViewController.stagePresenterViewController.checkResourcesAndPushViewController(to: self.navigationController!) { + self.scriptsViewController.hideLoadingView() + } + } + } + } + } diff --git a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h index c4d2a294a9..e1158cede8 100644 --- a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h +++ b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h @@ -28,6 +28,7 @@ @property (nonatomic, strong) PlaceHolderView *placeHolderView; @property (nonatomic, assign) BOOL allBricksSelected; +@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; - (void)showPlaceHolder:(BOOL)show; - (void)setupToolBar; diff --git a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m index 45ebd630fb..b72a9dfc70 100644 --- a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m +++ b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m @@ -33,7 +33,6 @@ @interface BaseCollectionViewController () @property (nonatomic, strong) LoadingView* loadingView; -@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; @end @implementation BaseCollectionViewController diff --git a/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift b/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift index 19f3d7d2a2..dd8d879c77 100644 --- a/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift +++ b/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift @@ -24,7 +24,7 @@ import BluetoothHelper import CoreBluetooth import UIKit -@objc extension StagePresenterViewController { +@objc public extension StagePresenterViewController { @objc(checkResourcesAndPushViewControllerTo:completion:) func checkResourcesAndPushViewController(to navigationController: UINavigationController, completion: @escaping () -> Void = {}) { From 7c59012c9fc2ee7f48e1fa6f5a1decb81d6c58a2 Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Sun, 16 Jul 2023 15:23:05 +0200 Subject: [PATCH 05/14] CATTY-710 Turn object overview from list to segments Fixed the dequeue error but tables are still not displayed correctly --- .../ObjectSwiftTableViewController.swift | 61 +++-- src/Catty/Storyboard+XIB/iPhone.storyboard | 234 +++++++++--------- .../BaseCollectionViewController.m | 2 +- .../BaseTableViewController.h | 1 + .../BaseTableViewController.m | 3 +- .../MaintainLooks/LooksTableViewController.m | 2 + .../SoundsTableViewController.m | 9 +- 7 files changed, 172 insertions(+), 140 deletions(-) diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift index 82e00e082b..8c01a40b97 100644 --- a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift @@ -30,7 +30,7 @@ class ObjectSwiftTableViewController: UIViewController { public var object: SpriteObject? var soundViewController = SoundsTableViewController() - //var looksViewController = LooksTableViewController() + var looksViewController = LooksTableViewController() var scriptsViewController = ScriptCollectionViewController(collectionViewLayout: type(of: UICollectionViewFlowLayout()).init()) override func viewDidLoad() { @@ -49,27 +49,22 @@ class ObjectSwiftTableViewController: UIViewController { func configureViewControllers() { scriptsViewController.object = object soundViewController.object = object + looksViewController.object = object + scriptsContainerView.addSubview(looksViewController.view) + looksViewController.view.frame = scriptsContainerView.bounds + scriptsContainerView.addSubview(scriptsViewController.view) //scriptsContainerView.addSubview(looksViewController.view) scriptsContainerView.addSubview(soundViewController.view) - //scriptsViewController.didMove(toParent: self) - scriptsViewController.view.frame = scriptsContainerView.bounds - //soundViewController.didMove(toParent: self) + scriptsViewController.view.frame = scriptsContainerView.bounds soundViewController.view.frame = scriptsContainerView.bounds -// looksViewController.didMove(toParent: self) -// looksViewController.view.frame = scriptsContainerView.bounds - - - //looksViewController.object = object scriptsViewController.view.isHidden = false - //looksViewController.view.isHidden = true + looksViewController.view.isHidden = true soundViewController.view.isHidden = true - - //looksViewController.setupToolBar() } func configureSegmentedControll() { @@ -85,9 +80,7 @@ class ObjectSwiftTableViewController: UIViewController { case 0: showScripts() case 1: - scriptsViewController.view.isHidden = true - //looksViewController.view.isHidden = false - soundViewController.view.isHidden = true + showBackgrounds() case 2: showSounds() default: @@ -99,16 +92,22 @@ class ObjectSwiftTableViewController: UIViewController { self.object = object } + func showBackgrounds() { + scriptsViewController.view.isHidden = true + looksViewController.view.isHidden = false + soundViewController.view.isHidden = true + } + func showScripts() { scriptsViewController.view.isHidden = false - //looksViewController.view.isHidden = true + looksViewController.view.isHidden = true soundViewController.view.isHidden = true setupToolBarForScripts() } func showSounds() { scriptsViewController.view.isHidden = true - //looksViewController.view.isHidden = true + looksViewController.view.isHidden = true soundViewController.view.isHidden = false setupToolBarForSound() } @@ -122,7 +121,7 @@ class ObjectSwiftTableViewController: UIViewController { func setupToolBarForSound() { let add = UIBarButtonItem(barButtonSystemItem: .add, target: soundViewController, action: #selector(soundViewController.addSoundAction(_:))) - let play = PlayButton(target: soundViewController, action: #selector(soundViewController.playSceneAction(_:))) + let play = PlayButton(target: self, action: #selector(soundPlayButtonPressed)) let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) self.toolbarItems = [flex, add, flex, flex, play, flex] } @@ -131,6 +130,32 @@ class ObjectSwiftTableViewController: UIViewController { playSceneAction(UIBarButtonItem()) } + @objc func soundPlayButtonPressed() { + soundViewController.playSceneAction(nil) + playSoundSceneAction(UIBarButtonItem()) + } + + func playSoundSceneAction(_ sender: Any) { + soundViewController.showLoadingView() + + (UIApplication.shared.delegate as? AppDelegate)?.enabledOrientation = true + let lastProjectQueue = DispatchQueue(label: "lastProjectQueue") + lastProjectQueue.async { + let landscapeMode = Project.lastUsed().header.landscapeMode + DispatchQueue.main.async { [self] in + if !landscapeMode { + UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation") + } else { + UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation") + } + + soundViewController.stagePresenterViewController.checkResourcesAndPushViewController(to: self.navigationController!) { + self.soundViewController.hideLoadingView() + } + } + } + } + func playSceneAction(_ sender: Any) { scriptsViewController.showLoadingView() diff --git a/src/Catty/Storyboard+XIB/iPhone.storyboard b/src/Catty/Storyboard+XIB/iPhone.storyboard index 80bd1c8d38..8fcf873d34 100644 --- a/src/Catty/Storyboard+XIB/iPhone.storyboard +++ b/src/Catty/Storyboard+XIB/iPhone.storyboard @@ -671,186 +671,186 @@ - + - - + + - - - - - - - + + + + + + - - + + - + - - + + - - - - - - + + + + + + + + + + - - - - - + + - - - - - - - - - + + - - - - - - - - + + + + + + + + + - - - + + + - - - + + - - - + - - + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + diff --git a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m index b72a9dfc70..af2c197330 100644 --- a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m +++ b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m @@ -190,7 +190,7 @@ - (void)showLoadingView self.navigationController.navigationBar.userInteractionEnabled = NO; self.navigationController.toolbar.userInteractionEnabled = NO; self.navigationController.interactivePopGestureRecognizer.enabled = NO; - [self showPlaceHolder:NO]; + //[self showPlaceHolder:NO]; [self.loadingView show]; } diff --git a/src/Catty/ViewController/BaseViewController/BaseTableViewController.h b/src/Catty/ViewController/BaseViewController/BaseTableViewController.h index e63e291c38..31acea4905 100644 --- a/src/Catty/ViewController/BaseViewController/BaseTableViewController.h +++ b/src/Catty/ViewController/BaseViewController/BaseTableViewController.h @@ -29,6 +29,7 @@ @property (nonatomic, strong) NSArray *editableSections; @property (nonatomic, strong, readonly) UIBarButtonItem *selectAllRowsButtonItem; @property (nonatomic, strong) PlaceHolderView *placeHolderView; +@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; - (void)setStagePresenterViewController:(StagePresenterViewController*) mockViewController; - (void)showPlaceHolder:(BOOL)show; diff --git a/src/Catty/ViewController/BaseViewController/BaseTableViewController.m b/src/Catty/ViewController/BaseViewController/BaseTableViewController.m index a3266cad9e..b863478394 100644 --- a/src/Catty/ViewController/BaseViewController/BaseTableViewController.m +++ b/src/Catty/ViewController/BaseViewController/BaseTableViewController.m @@ -40,7 +40,6 @@ @interface BaseTableViewController () @property (nonatomic, strong) LoadingView* loadingView; @property (nonatomic, strong) UIBarButtonItem *selectAllRowsButtonItem; @property (nonatomic, strong) UIBarButtonItem *normalModeRightBarButtonItem; -@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; @end @implementation BaseTableViewController @@ -438,7 +437,7 @@ - (void)showLoadingView self.navigationController.navigationBar.userInteractionEnabled = NO; self.navigationController.toolbar.userInteractionEnabled = NO; self.navigationController.interactivePopGestureRecognizer.enabled = NO; - [self showPlaceHolder:NO]; + //[self showPlaceHolder:NO]; [self.loadingView show]; } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m index 7d6e67b3fd..3e784af6f0 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m @@ -82,6 +82,8 @@ - (void)viewDidLoad if(self.showAddLookActionSheetAtStartForScriptEditor || self.showAddLookActionSheetAtStartForObject) { [self showAddLookActionSheet]; } + [self.tableView registerClass:[DarkBlueGradientImageCell class] forCellReuseIdentifier:kImageCell]; + [self.tableView registerClass:[DarkBlueGradientImageDetailCell class] forCellReuseIdentifier:kDetailImageCell]; } #pragma mark viewwillappear diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m index 057937465a..462adbb0a1 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m @@ -68,7 +68,8 @@ - (void)viewDidLoad self.currentPlayingSong = nil; self.currentPlayingSongCell = nil; self.placeHolderView.title = kLocalizedTapPlusToAddSound; - [self showPlaceHolder:(! (BOOL)[self.object.soundList count])]; + //[self showPlaceHolder:(! (BOOL)[self.object.soundList count])]; + self.placeHolderView.hidden = (self.object.soundList.count != 0); [self setupToolBar]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; self.isAllowed = YES; @@ -76,6 +77,9 @@ - (void)viewDidLoad if(self.showAddSoundActionSheetAtStart) { [self addSoundAction:nil]; } + [self.tableView registerClass:[DarkBlueGradientImageCell class] forCellReuseIdentifier:kImageCell]; + [self.tableView registerClass:[DarkBlueGradientImageDetailCell class] forCellReuseIdentifier:kDetailImageCell]; + } - (void)viewWillAppear:(BOOL)animated @@ -83,6 +87,7 @@ - (void)viewWillAppear:(BOOL)animated [super viewWillAppear:animated]; [self.navigationController setToolbarHidden:NO]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; + } - (void)viewWillDisappear:(BOOL)animated @@ -96,7 +101,7 @@ - (void)viewWillDisappear:(BOOL)animated - (void)playSceneAction:(id)sender { [self stopAllSounds]; - [super playSceneAction:sender]; + //[super playSceneAction:sender]; } #pragma mark - actions From 02a1fff73311e8654903c0c1168b5f2671b25596 Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Mon, 17 Jul 2023 11:35:40 +0200 Subject: [PATCH 06/14] CATTY-710 Turn object overview from list to segments Now using Container Views with segues which makes life much easier in this case --- .../ObjectSwiftTableViewController.swift | 118 +++++++++++------- src/Catty/Storyboard+XIB/iPhone.storyboard | 71 +++++++---- .../MaintainLooks/LooksTableViewController.h | 1 + .../MaintainLooks/LooksTableViewController.m | 5 +- 4 files changed, 123 insertions(+), 72 deletions(-) diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift index 8c01a40b97..8508a75529 100644 --- a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/ObjectSwiftTableViewController.swift @@ -25,46 +25,42 @@ import UIKit class ObjectSwiftTableViewController: UIViewController { @IBOutlet private weak var objectSegmentedControl: UISegmentedControl! - + @IBOutlet private weak var soundContainerView: UIView! @IBOutlet private weak var scriptsContainerView: UIView! + @IBOutlet private weak var looksContainerView: UIView! public var object: SpriteObject? - var soundViewController = SoundsTableViewController() - var looksViewController = LooksTableViewController() - var scriptsViewController = ScriptCollectionViewController(collectionViewLayout: type(of: UICollectionViewFlowLayout()).init()) + var soundViewController: SoundsTableViewController? + var looksViewController: LooksTableViewController? + var scriptsViewController: ScriptCollectionViewController? override func viewDidLoad() { super.viewDidLoad() configureSegmentedControll() + scriptsContainerView.isHidden = true if let object = object { self.title = object.name self.navigationItem.title = object.name } navigationController?.setToolbarHidden(false, animated: true) - configureViewControllers() - setupToolBarForScripts() + showScripts() } - func configureViewControllers() { - scriptsViewController.object = object - soundViewController.object = object - looksViewController.object = object - scriptsContainerView.addSubview(looksViewController.view) - looksViewController.view.frame = scriptsContainerView.bounds - - - scriptsContainerView.addSubview(scriptsViewController.view) - //scriptsContainerView.addSubview(looksViewController.view) - scriptsContainerView.addSubview(soundViewController.view) - - scriptsViewController.view.frame = scriptsContainerView.bounds - soundViewController.view.frame = scriptsContainerView.bounds - - - scriptsViewController.view.isHidden = false - looksViewController.view.isHidden = true - soundViewController.view.isHidden = true + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "toLooks" { + let destVC = segue.destination as! LooksTableViewController + destVC.object = object + looksViewController = destVC + } else if segue.identifier == "toSounds" { + let destVC = segue.destination as! SoundsTableViewController + destVC.object = object + soundViewController = destVC + } else if segue.identifier == "toScripts" { + let destVC = segue.destination as! ScriptCollectionViewController + destVC.object = object + scriptsViewController = destVC + } } func configureSegmentedControll() { @@ -86,33 +82,38 @@ class ObjectSwiftTableViewController: UIViewController { default: break } - } + @objc func setObject(_ object: SpriteObject) { self.object = object } func showBackgrounds() { - scriptsViewController.view.isHidden = true - looksViewController.view.isHidden = false - soundViewController.view.isHidden = true + scriptsContainerView.isHidden = true + looksContainerView.isHidden = false + soundContainerView.isHidden = true + setUpToolBarForLooks() } func showScripts() { - scriptsViewController.view.isHidden = false - looksViewController.view.isHidden = true - soundViewController.view.isHidden = true + scriptsContainerView.isHidden = false + looksContainerView.isHidden = true + soundContainerView.isHidden = true setupToolBarForScripts() } func showSounds() { - scriptsViewController.view.isHidden = true - looksViewController.view.isHidden = true - soundViewController.view.isHidden = false + scriptsContainerView.isHidden = true + looksContainerView.isHidden = true + soundContainerView.isHidden = false setupToolBarForSound() } func setupToolBarForScripts() { + + guard let scriptsViewController = scriptsViewController else { + return + } let add = UIBarButtonItem(barButtonSystemItem: .add, target: scriptsViewController, action: #selector(scriptsViewController.showBrickPickerAction)) let play = PlayButton(target: self, action: #selector(scriptPlayButtonPressed)) let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) @@ -120,23 +121,48 @@ class ObjectSwiftTableViewController: UIViewController { } func setupToolBarForSound() { + guard let soundViewController = soundViewController else { + return + } let add = UIBarButtonItem(barButtonSystemItem: .add, target: soundViewController, action: #selector(soundViewController.addSoundAction(_:))) let play = PlayButton(target: self, action: #selector(soundPlayButtonPressed)) let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) self.toolbarItems = [flex, add, flex, flex, play, flex] } + func setUpToolBarForLooks() { + guard let looksViewController = looksViewController else { + return + } + let add = UIBarButtonItem(barButtonSystemItem: .add, target: looksViewController, action: #selector(looksViewController.addLookAction(_:))) + let play = PlayButton(target: self, action: #selector(looksPlayButtonPressed)) + let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil) + self.toolbarItems = [flex, add, flex, flex, play, flex] + } + @objc func scriptPlayButtonPressed() { - playSceneAction(UIBarButtonItem()) + if let scriptsViewController = scriptsViewController { + playScriptsSceneAction(scriptsViewController) + } + } @objc func soundPlayButtonPressed() { + guard let soundViewController = soundViewController else { + return + } soundViewController.playSceneAction(nil) - playSoundSceneAction(UIBarButtonItem()) + playBaseTableViewSceneAction(soundViewController) + } + + @objc func looksPlayButtonPressed() { + if let looksViewController { + playBaseTableViewSceneAction(looksViewController) + } } - func playSoundSceneAction(_ sender: Any) { - soundViewController.showLoadingView() + func playBaseTableViewSceneAction(_ sender: BaseTableViewController) { + sender.showLoadingView() (UIApplication.shared.delegate as? AppDelegate)?.enabledOrientation = true let lastProjectQueue = DispatchQueue(label: "lastProjectQueue") @@ -149,16 +175,15 @@ class ObjectSwiftTableViewController: UIViewController { UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation") } - soundViewController.stagePresenterViewController.checkResourcesAndPushViewController(to: self.navigationController!) { - self.soundViewController.hideLoadingView() + sender.stagePresenterViewController.checkResourcesAndPushViewController(to: self.navigationController!) { + sender.hideLoadingView() } } } } - func playSceneAction(_ sender: Any) { - scriptsViewController.showLoadingView() - + func playScriptsSceneAction(_ sender: ScriptCollectionViewController) { + sender.showLoadingView() (UIApplication.shared.delegate as? AppDelegate)?.enabledOrientation = true let lastProjectQueue = DispatchQueue(label: "lastProjectQueue") lastProjectQueue.async { @@ -169,9 +194,8 @@ class ObjectSwiftTableViewController: UIViewController { } else { UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation") } - - scriptsViewController.stagePresenterViewController.checkResourcesAndPushViewController(to: self.navigationController!) { - self.scriptsViewController.hideLoadingView() + sender.stagePresenterViewController.checkResourcesAndPushViewController(to: self.navigationController!) { + sender.hideLoadingView() } } } diff --git a/src/Catty/Storyboard+XIB/iPhone.storyboard b/src/Catty/Storyboard+XIB/iPhone.storyboard index 8fcf873d34..72c77d94b3 100644 --- a/src/Catty/Storyboard+XIB/iPhone.storyboard +++ b/src/Catty/Storyboard+XIB/iPhone.storyboard @@ -242,23 +242,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -270,7 +295,7 @@ - + @@ -301,19 +326,19 @@ - + - + - + - + - + @@ -377,7 +402,7 @@ - + - + @@ -283,7 +283,7 @@ - + @@ -826,44 +826,44 @@ + + + - - - - - - + + - + + - - + - + + + + + - - - - - + + - + + - - + diff --git a/src/Catty/Supporting Files/Catty-Bridging-Header.h b/src/Catty/Supporting Files/Catty-Bridging-Header.h index 4908856feb..9aab3cc51a 100644 --- a/src/Catty/Supporting Files/Catty-Bridging-Header.h +++ b/src/Catty/Supporting Files/Catty-Bridging-Header.h @@ -173,7 +173,6 @@ #import "CatrobatTableViewController.h" #import "ScriptCollectionViewController.h" #import "ProjectDetailStoreViewController.h" -#import "ObjectTableViewController.h" //------------------------------------------------------------------------------------------------------------ diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m index ab84f5bf25..0c2a780c4c 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m @@ -148,7 +148,6 @@ - (void)changeToMoveMode:(id)sender [self.tableView reloadData]; [self.tableView setEditing:YES animated:YES]; self.tableView.allowsMultipleSelectionDuringEditing = NO; - self.parentNavigationController.navigationController.toolbar.userInteractionEnabled = NO; self.parentNavigationController.navigationController.toolbar.hidden = true; self.editing = YES; } @@ -171,7 +170,6 @@ - (void)exitEditingMode { self.parentNavigationController.navigationItem.hidesBackButton = NO; [self initNavigationBar]; - self.parentNavigationController.navigationController.toolbar.userInteractionEnabled = YES; [self.tableView setEditing:NO animated:YES]; [self setupToolBar]; self.editing = NO; diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h index 7ac9ae6d75..b5f6dee1ac 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h @@ -24,10 +24,12 @@ #import "BaseCollectionViewController.h" @class SpriteObject; +@protocol EnableAndDisableSegmentedControllDelegate; @interface ScriptCollectionViewController : BaseCollectionViewController @property (nonatomic, strong) SpriteObject *object; @property (nonatomic, strong) UIViewController *parentNavigationController; +@property (weak, nonatomic) id segmentedControllDelegate; - (void)removeBrickOrScript:(id)scriptOrBrick atIndexPath:(NSIndexPath*)indexPath; diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m index 4deb1b2aac..67f63f4661 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m @@ -370,6 +370,7 @@ - (void)deleteAlertView addDefaultActionWithTitle:kLocalizedYes handler:^{ [self deleteSelectedBricks]; self.allBricksSelected = NO; + [self.segmentedControllDelegate enableSegmentedControll]; }] build] showWithController:self]; } @@ -1180,6 +1181,7 @@ -(void)enableUserInteractionAndResetHighlight for (BrickCell *cell in self.collectionView.visibleCells) { cell.enabled = YES; cell.alpha = kBrickCellActiveOpacity; + [self.segmentedControllDelegate enableSegmentedControll]; } CGFloat maxContentOffset = self.collectionView.contentSize.height + self.collectionView.contentInset.bottom - self.collectionView.bounds.size.height; @@ -1199,17 +1201,18 @@ -(void)disableUserInteractionAndHighlight:(BrickCell*)brickCell withMarginBottom collectionViewLayout.longPressGestureRecognizer.enabled = NO; self.collectionView.scrollEnabled = NO; self.isEditingBrickMode = YES; - self.navigationController.toolbar.userInteractionEnabled = NO; - self.navigationController.navigationBar.userInteractionEnabled = NO; + self.parentNavigationController.navigationController.toolbar.userInteractionEnabled = NO; + self.parentNavigationController.navigationController.navigationBar.userInteractionEnabled = NO; // disable swipe back gesture - if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { - self.navigationController.interactivePopGestureRecognizer.enabled = NO; + if ([self.parentNavigationController.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { + self.parentNavigationController.navigationController.interactivePopGestureRecognizer.enabled = NO; } for (BrickCell *cell in self.collectionView.visibleCells) { if (cell != brickCell) { cell.enabled = NO; cell.alpha = kBrickCellInactiveWhileEditingOpacity; + [self.segmentedControllDelegate disableSegmentedControll]; } } @@ -1294,6 +1297,7 @@ - (void)selectAllRows:(id)sender -(void)enterDeleteMode { + [self.segmentedControllDelegate disableSegmentedControll]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel style:UIBarButtonItemStylePlain target:self action:@selector(exitDeleteMode)]; self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; @@ -1336,6 +1340,7 @@ -(void)exitDeleteMode }]; self.editing = NO; self.allBricksSelected = NO; + [self.segmentedControllDelegate enableSegmentedControll]; } -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h index 5b3988ef72..3c5a8803f0 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h @@ -25,6 +25,7 @@ @class SpriteObject; @class Sound; +@protocol EnableAndDisableSegmentedControllDelegate; @protocol SoundDelegate - (void)addSound:(Sound *)sound; @@ -36,6 +37,7 @@ @property (strong, nonatomic) SpriteObject *object; @property (nonatomic) BOOL showAddSoundActionSheetAtStart; +@property (weak, nonatomic) id segmentedControllDelegate; @property (nonatomic, strong) UIViewController *parentNavigationController; @property (copy) void (^afterSafeBlock)(Sound* look); - (void)playSceneAction:(id)sender; diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m index 79b0dac16c..b7b34f62db 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m @@ -587,6 +587,7 @@ - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)fl - (void)changeToMoveMode:(id)sender { + [self.segmentedControllDelegate disableSegmentedControll]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedDone style:UIBarButtonItemStylePlain target:self @@ -596,12 +597,13 @@ - (void)changeToMoveMode:(id)sender [self.tableView reloadData]; [self.tableView setEditing:YES animated:YES]; self.tableView.allowsMultipleSelectionDuringEditing = NO; - self.parentNavigationController.navigationController.toolbar.userInteractionEnabled = NO; + self.parentNavigationController.navigationController.toolbar.hidden = true; self.editing = YES; } - (void)changeToEditingMode:(id)sender { + [self.segmentedControllDelegate disableSegmentedControll]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel style:UIBarButtonItemStylePlain target:self @@ -620,10 +622,11 @@ - (void)exitEditingMode self.deletionMode = NO; self.parentNavigationController.navigationItem.hidesBackButton = NO; [self initNavigationBar]; - self.parentNavigationController.navigationController.toolbar.userInteractionEnabled = YES; + self.parentNavigationController.navigationController.toolbar.hidden = false; [self.tableView setEditing:NO animated:YES]; [self setupToolBar]; self.editing = NO; + [self.segmentedControllDelegate enableSegmentedControll]; } #pragma mark - Helper Methods diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h deleted file mode 100644 index 1c46d56160..0000000000 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (C) 2010-2023 The Catrobat Team - * (http://developer.catrobat.org/credits) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * (http://developer.catrobat.org/license_additional_term) - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#import -#import "BaseTableViewController.h" - -@class SpriteObject; - -@interface ObjectTableViewController : BaseTableViewController -@property (weak, nonatomic) IBOutlet UISegmentedControl *objectSegementedControl; - -@property (strong, nonatomic) SpriteObject *object; -@end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m deleted file mode 100644 index d7fe3f9ef6..0000000000 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright (C) 2010-2023 The Catrobat Team - * (http://developer.catrobat.org/credits) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * (http://developer.catrobat.org/license_additional_term) - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#import "ObjectTableViewController.h" -#import "ScriptCollectionViewController.h" -#import "LooksTableViewController.h" -#import "SoundsTableViewController.h" -#import "SegueDefines.h" -#import "TableUtil.h" -#import "CatrobatImageCell.h" -#import "Util.h" -#import "Pocket_Code-Swift.h" - -@interface ObjectTableViewController () - -@end - -@implementation ObjectTableViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - self.title = self.object.name; - self.navigationItem.title = self.object.name; - [self setupToolBar]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; -} - -#pragma mark - Table view data source -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 1; -} - -- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section -{ - return 3; -} - -- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath -{ - static NSString *CellIdentifier = @"MenuCell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; - - if ([cell conformsToProtocol:@protocol(CatrobatImageCell)]) { - UITableViewCell *imageCell = (UITableViewCell*)cell; - switch (indexPath.row) { - case 0: - imageCell.iconImageView.image = [UIImage imageNamed:@"catrobat.scripts"]; - imageCell.titleLabel.text = kLocalizedScripts; - break; - case 1: - imageCell.iconImageView.image = [UIImage imageNamed:@"eye.fill"]; - imageCell.titleLabel.text = (self.object.isBackground - ? kLocalizedBackgrounds - : kLocalizedLooks); - break; - case 2: - imageCell.iconImageView.image = [UIImage imageNamed:@"speaker.wave.2.fill"]; - imageCell.titleLabel.text = kLocalizedSounds; - break; - } - - imageCell.iconImageView.contentMode = UIViewContentModeScaleAspectFit; - imageCell.iconImageView.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; - } - return cell; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return [TableUtil heightForImageCell]; -} - -#pragma mark - table view delegates -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Pass the selected object to the new view controller - static NSString *toScriptsSegueID = kSegueToScripts; - static NSString *toLooksSegueID = kSegueToLooks; - static NSString *toSoundsSegueID = kSegueToSounds; - - UITableViewCell* sender = [tableView cellForRowAtIndexPath:indexPath]; - if (indexPath.row == 0) - [self performSegueWithIdentifier:toScriptsSegueID sender:sender]; - else if (indexPath.row == 1) - [self performSegueWithIdentifier:toLooksSegueID sender:sender]; - else if (indexPath.row == 2) - [self performSegueWithIdentifier:toSoundsSegueID sender:sender]; - - [tableView deselectRowAtIndexPath:indexPath animated:YES]; -} - -#pragma mark - segue handlers -- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender -{ - // Pass the selected object to the new view controller. - static NSString *toScriptsSegueID = kSegueToScripts; - static NSString *toLooksSegueID = kSegueToLooks; - static NSString *toSoundsSegueID = kSegueToSounds; - - UIViewController* destController = segue.destinationViewController; - if ([sender isKindOfClass:[UITableViewCell class]]) { - if (([segue.identifier isEqualToString:toScriptsSegueID] || - [segue.identifier isEqualToString:toLooksSegueID] || - [segue.identifier isEqualToString:toSoundsSegueID]) && - [destController respondsToSelector:@selector(setObject:)]) { - [destController performSelector:@selector(setObject:) withObject:self.object]; - } - } -} - -#pragma mark - helpers -- (void)setupToolBar -{ - [super setupToolBar]; - - UIBarButtonItem *play = [[PlayButton alloc] initWithTarget:self - action:@selector(playSceneAction:)]; - UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace - target:self - action:nil]; - self.toolbarItems = [NSArray arrayWithObjects: flex, play, flex, nil]; -} - -@end diff --git a/src/Catty/ViewController/ObjectSwiftTableViewController.swift b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift similarity index 90% rename from src/Catty/ViewController/ObjectSwiftTableViewController.swift rename to src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift index 4eb667f1df..7ee37ddc89 100644 --- a/src/Catty/ViewController/ObjectSwiftTableViewController.swift +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift @@ -22,15 +22,15 @@ import UIKit -class ObjectSwiftTableViewController: UIViewController { +class ObjectViewController: UIViewController, EnableAndDisableSegmentedControllDelegate { @IBOutlet private weak var objectSegmentedControl: UISegmentedControl! - @IBOutlet private weak var soundContainerView: UIView! + @IBOutlet private weak var soundsContainerView: UIView! @IBOutlet private weak var scriptsContainerView: UIView! @IBOutlet private weak var looksContainerView: UIView! public var object: SpriteObject? - var soundViewController: SoundsTableViewController? + var soundsViewController: SoundsTableViewController? var looksViewController: LooksTableViewController? var scriptsViewController: ScriptCollectionViewController? @@ -80,11 +80,13 @@ class ObjectSwiftTableViewController: UIViewController { } else if segue.identifier == "toSounds" { let destVC = segue.destination as! SoundsTableViewController destVC.object = object + destVC.segmentedControllDelegate = self destVC.parentNavigationController = self - soundViewController = destVC + soundsViewController = destVC } else if segue.identifier == "toScripts" { let destVC = segue.destination as! ScriptCollectionViewController destVC.object = object + destVC.segmentedControllDelegate = self destVC.parentNavigationController = self scriptsViewController = destVC } @@ -120,7 +122,7 @@ class ObjectSwiftTableViewController: UIViewController { func showBackgrounds() { scriptsContainerView.isHidden = true looksContainerView.isHidden = false - soundContainerView.isHidden = true + soundsContainerView.isHidden = true looksViewController?.initNavigationBar() looksViewController?.setupToolBar() } @@ -128,7 +130,7 @@ class ObjectSwiftTableViewController: UIViewController { func showScripts() { scriptsContainerView.isHidden = false looksContainerView.isHidden = true - soundContainerView.isHidden = true + soundsContainerView.isHidden = true scriptsViewController?.setupToolBar() scriptsViewController?.changeDeleteBarButtonState() } @@ -136,14 +138,11 @@ class ObjectSwiftTableViewController: UIViewController { func showSounds() { scriptsContainerView.isHidden = true looksContainerView.isHidden = true - soundContainerView.isHidden = false - soundViewController?.initNavigationBar() - soundViewController?.setupToolBar() + soundsContainerView.isHidden = false + soundsViewController?.initNavigationBar() + soundsViewController?.setupToolBar() } -} - -extension ObjectSwiftTableViewController: EnableAndDisableSegmentedControllDelegate { func enableSegmentedControll() { objectSegmentedControl.isEnabled = true } @@ -151,4 +150,5 @@ extension ObjectSwiftTableViewController: EnableAndDisableSegmentedControllDeleg func disableSegmentedControll() { objectSegmentedControl.isEnabled = false } + } diff --git a/src/Catty/ViewController/Continue&New/SceneTableViewController.m b/src/Catty/ViewController/Continue&New/SceneTableViewController.m index acd09281f0..34bdc3653f 100644 --- a/src/Catty/ViewController/Continue&New/SceneTableViewController.m +++ b/src/Catty/ViewController/Continue&New/SceneTableViewController.m @@ -22,7 +22,6 @@ #import "SceneTableViewController.h" #import "TableUtil.h" -#import "ObjectTableViewController.h" #import "SegueDefines.h" #import "Brick.h" #import "CatrobatImageCell.h" @@ -632,8 +631,8 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender UITableViewCell *cell = (UITableViewCell*) sender; NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; if ([segue.identifier isEqualToString:toObjectSegueID]) { - if ([destController isKindOfClass:[ObjectSwiftTableViewController class]]) { - ObjectSwiftTableViewController *tvc = (ObjectSwiftTableViewController*) destController; + if ([destController isKindOfClass:[ObjectViewController class]]) { + ObjectViewController *tvc = (ObjectViewController*) destController; if ([tvc respondsToSelector:@selector(setObject:)]) { SpriteObject* object = [self.scene.objects objectAtIndex:(kBackgroundObjectIndex + indexPath.section + indexPath.row)]; From 97c54a5143757bc6ae0565f9bce0024e960971c6 Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Wed, 19 Jul 2023 14:38:36 +0200 Subject: [PATCH 13/14] CATTY-710 Turn object overview from list to segments Fixed Bug where Delete Button on Scrips was disabled when backgrounds list was empty. --- .../MaintainObject/MaintainLooks/LooksTableViewController.m | 1 - .../MaintainScript/ScriptCollectionViewController.h | 1 + .../MaintainScript/ScriptCollectionViewController.m | 4 ++-- .../MaintainObject/MaintainSounds/SoundsTableViewController.m | 4 ++-- .../Continue&New/MaintainObject/ObjectViewController.swift | 2 -- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m index 0c2a780c4c..d26b55a756 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m @@ -88,7 +88,6 @@ - (void)viewDidLoad - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self reloadData]; } #pragma mark - actions diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h index b5f6dee1ac..50f43236d3 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h @@ -34,6 +34,7 @@ - (void)removeBrickOrScript:(id)scriptOrBrick atIndexPath:(NSIndexPath*)indexPath; -(void)turnOnInsertingBrickMode; +-(void)reloadData; - (void)showBrickPickerAction:(id)sender; - (void)changeDeleteBarButtonState; diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m index 67f63f4661..c23d5c6c90 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m @@ -800,7 +800,7 @@ -(void)turnOnInsertingBrickMode layout.longPressGestureRecognizer.minimumPressDuration = 0.1; [self.navigationItem setHidesBackButton:YES animated:NO]; dispatch_async(dispatch_get_main_queue(), ^{ - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; }); } @@ -815,7 +815,7 @@ -(void)turnOffInsertingBrickMode layout.longPressGestureRecognizer.minimumPressDuration = 0.5; [self.navigationItem setHidesBackButton:NO animated:NO]; dispatch_async(dispatch_get_main_queue(), ^{ - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; }); } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m index b7b34f62db..c7e7d165ab 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m @@ -737,9 +737,9 @@ - (void)setupEditingToolBar - (void)changeEditingBarButtonState { if (self.object.soundList.count >= 1) { - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; } else { - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; } } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift index 7ee37ddc89..67ce26ad3f 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift @@ -111,8 +111,6 @@ class ObjectViewController: UIViewController, EnableAndDisableSegmentedControllD default: break } - objectSegmentedControl.isMomentary = true - objectSegmentedControl.isMomentary = false } @objc func setObject(_ object: SpriteObject) { From 0ea272b4f446bd90250a5d50b0d2eeb6ec331c85 Mon Sep 17 00:00:00 2001 From: Luca Topolovec Date: Thu, 17 Aug 2023 15:49:46 +0200 Subject: [PATCH 14/14] Catty 710 turn object overview from list to segments --- src/Catty.xcodeproj/project.pbxproj | 10 +- src/Catty/Storyboard+XIB/iPhone.storyboard | 355 +++++++++--------- .../BaseCollectionViewController.h | 1 + .../BaseCollectionViewController.m | 3 +- .../BaseTableViewController.h | 1 + .../BaseTableViewController.m | 3 +- .../MaintainLooks/LooksTableViewController.h | 10 + .../MaintainLooks/LooksTableViewController.m | 70 +++- .../ScriptCollectionViewController.h | 8 + .../ScriptCollectionViewController.m | 47 ++- .../SoundsTableViewController.h | 7 + .../SoundsTableViewController.m | 59 ++- .../ObjectTableViewController.h | 30 -- .../ObjectTableViewController.m | 150 -------- .../MaintainObject/ObjectViewController.swift | 152 ++++++++ .../Continue&New/SceneTableViewController.m | 8 +- ...nterViewControllerResourcesExtension.swift | 2 +- 17 files changed, 518 insertions(+), 398 deletions(-) delete mode 100644 src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h delete mode 100644 src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m create mode 100644 src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift diff --git a/src/Catty.xcodeproj/project.pbxproj b/src/Catty.xcodeproj/project.pbxproj index a55b5f5c55..86e2271586 100644 --- a/src/Catty.xcodeproj/project.pbxproj +++ b/src/Catty.xcodeproj/project.pbxproj @@ -1356,7 +1356,6 @@ 92FF314E1A24DEB300093DA7 /* LookImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF311B1A24DEB300093DA7 /* LookImageViewController.m */; }; 92FF314F1A24DEB300093DA7 /* LooksTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF311D1A24DEB300093DA7 /* LooksTableViewController.m */; }; 92FF31551A24DEB300093DA7 /* SoundsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF312B1A24DEB300093DA7 /* SoundsTableViewController.m */; }; - 92FF31571A24DEB300093DA7 /* ObjectTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF312F1A24DEB300093DA7 /* ObjectTableViewController.m */; }; 92FF31581A24DEB300093DA7 /* SceneTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF31311A24DEB300093DA7 /* SceneTableViewController.m */; }; 92FF31591A24DEB300093DA7 /* DownloadTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF31341A24DEB300093DA7 /* DownloadTabBarController.m */; }; 92FF315B1A24DEB300093DA7 /* ProjectDetailStoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF31381A24DEB300093DA7 /* ProjectDetailStoreViewController.m */; }; @@ -1751,6 +1750,7 @@ AAF6D9DE1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DD1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift */; }; AAF6D9E01BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */; }; AAF6D9E21BC0C48300686849 /* PointToBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */; }; + B06830562A6007DC00BF06BD /* ObjectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B06830552A6007DC00BF06BD /* ObjectViewController.swift */; }; BA1FA9981F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA9971F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m */; }; BA1FA99D1F02AEDC0084184D /* InsertItemIntoUserListBrick.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99C1F02AEDC0084184D /* InsertItemIntoUserListBrick.m */; }; BA1FA9A01F02B0020084184D /* InsertItemIntoUserListBrickCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99F1F02B0020084184D /* InsertItemIntoUserListBrickCell.m */; }; @@ -3758,8 +3758,6 @@ 92FF311D1A24DEB300093DA7 /* LooksTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LooksTableViewController.m; sourceTree = ""; }; 92FF312A1A24DEB300093DA7 /* SoundsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoundsTableViewController.h; sourceTree = ""; }; 92FF312B1A24DEB300093DA7 /* SoundsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SoundsTableViewController.m; sourceTree = ""; }; - 92FF312E1A24DEB300093DA7 /* ObjectTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectTableViewController.h; sourceTree = ""; }; - 92FF312F1A24DEB300093DA7 /* ObjectTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectTableViewController.m; sourceTree = ""; }; 92FF31301A24DEB300093DA7 /* SceneTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneTableViewController.h; sourceTree = ""; }; 92FF31311A24DEB300093DA7 /* SceneTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SceneTableViewController.m; sourceTree = ""; }; 92FF31331A24DEB300093DA7 /* DownloadTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadTabBarController.h; sourceTree = ""; }; @@ -4395,6 +4393,7 @@ AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointInDirectionBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointInDirectionBrick+Instruction.swift"; sourceTree = ""; }; AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointToBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointToBrick+Instruction.swift"; sourceTree = ""; }; ABD74577198FBC2984BDDE56 /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = ""; }; + B06830552A6007DC00BF06BD /* ObjectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectViewController.swift; sourceTree = ""; }; B11EA657D0D5E2E348790671 /* ta */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ta; path = ta.lproj/Localizable.strings; sourceTree = ""; }; B46B270517703F9400172837 /* CattyTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CattyTests-Info.plist"; sourceTree = ""; }; B46B270717703F9400172837 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -9226,11 +9225,10 @@ 92FF31181A24DEB300093DA7 /* MaintainObject */ = { isa = PBXGroup; children = ( + B06830552A6007DC00BF06BD /* ObjectViewController.swift */, 92FF31191A24DEB300093DA7 /* MaintainLooks */, 92FF311E1A24DEB300093DA7 /* MaintainScript */, 92FF31271A24DEB300093DA7 /* MaintainSounds */, - 92FF312E1A24DEB300093DA7 /* ObjectTableViewController.h */, - 92FF312F1A24DEB300093DA7 /* ObjectTableViewController.m */, ); path = MaintainObject; sourceTree = ""; @@ -12886,6 +12884,7 @@ AA401FE91BBEF6F9001BC49F /* CBInstructionProtocol.swift in Sources */, AABCB3E21BB36529009F67D2 /* CBScheduler.swift in Sources */, BACDF3521F1F9B7E00346167 /* DeleteItemOfUserListBrick.m in Sources */, + B06830562A6007DC00BF06BD /* ObjectViewController.swift in Sources */, BB9EC0E527D62CBA009FF8CE /* FormTableViewCell.swift in Sources */, 4614B1DD25608E8B004174AD /* StitchBrickCell.swift in Sources */, AABCB3DF1BB3650B009F67D2 /* CBBackendProtocol.swift in Sources */, @@ -12994,7 +12993,6 @@ 4C2EE41E1B555B55006DE9B8 /* CBXMLOpenedNestingBricksStack.m in Sources */, 7B09EB6A29B1DF8200590F3D /* LoginViewController.swift in Sources */, 5EFBD5F92145533B003B3CDC /* ProjectDescriptionViewController.swift in Sources */, - 92FF31571A24DEB300093DA7 /* ObjectTableViewController.m in Sources */, 4CE3D68F2107B68600005629 /* VisualDetectionManagerProtocol.swift in Sources */, BB6FE23C2812BD4E007ABDA9 /* FormCrashReportsSwitchTableViewCell.swift in Sources */, 929CC0EF1BC39B8C0027DEC0 /* PhiroMotorStopBrickCell.m in Sources */, diff --git a/src/Catty/Storyboard+XIB/iPhone.storyboard b/src/Catty/Storyboard+XIB/iPhone.storyboard index 9a24cd1e38..8e51df0fe6 100644 --- a/src/Catty/Storyboard+XIB/iPhone.storyboard +++ b/src/Catty/Storyboard+XIB/iPhone.storyboard @@ -209,83 +209,93 @@ - + - + - - + + - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - + + - + - + @@ -316,19 +326,19 @@ - + - + - + - + - + @@ -392,7 +402,7 @@ @@ -1142,7 +1153,7 @@ - + @@ -1993,7 +2004,7 @@ - + @@ -2166,8 +2177,8 @@ - - + + diff --git a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h index c4d2a294a9..e1158cede8 100644 --- a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h +++ b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h @@ -28,6 +28,7 @@ @property (nonatomic, strong) PlaceHolderView *placeHolderView; @property (nonatomic, assign) BOOL allBricksSelected; +@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; - (void)showPlaceHolder:(BOOL)show; - (void)setupToolBar; diff --git a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m index 45ebd630fb..af2c197330 100644 --- a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m +++ b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m @@ -33,7 +33,6 @@ @interface BaseCollectionViewController () @property (nonatomic, strong) LoadingView* loadingView; -@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; @end @implementation BaseCollectionViewController @@ -191,7 +190,7 @@ - (void)showLoadingView self.navigationController.navigationBar.userInteractionEnabled = NO; self.navigationController.toolbar.userInteractionEnabled = NO; self.navigationController.interactivePopGestureRecognizer.enabled = NO; - [self showPlaceHolder:NO]; + //[self showPlaceHolder:NO]; [self.loadingView show]; } diff --git a/src/Catty/ViewController/BaseViewController/BaseTableViewController.h b/src/Catty/ViewController/BaseViewController/BaseTableViewController.h index e63e291c38..31acea4905 100644 --- a/src/Catty/ViewController/BaseViewController/BaseTableViewController.h +++ b/src/Catty/ViewController/BaseViewController/BaseTableViewController.h @@ -29,6 +29,7 @@ @property (nonatomic, strong) NSArray *editableSections; @property (nonatomic, strong, readonly) UIBarButtonItem *selectAllRowsButtonItem; @property (nonatomic, strong) PlaceHolderView *placeHolderView; +@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; - (void)setStagePresenterViewController:(StagePresenterViewController*) mockViewController; - (void)showPlaceHolder:(BOOL)show; diff --git a/src/Catty/ViewController/BaseViewController/BaseTableViewController.m b/src/Catty/ViewController/BaseViewController/BaseTableViewController.m index a3266cad9e..b863478394 100644 --- a/src/Catty/ViewController/BaseViewController/BaseTableViewController.m +++ b/src/Catty/ViewController/BaseViewController/BaseTableViewController.m @@ -40,7 +40,6 @@ @interface BaseTableViewController () @property (nonatomic, strong) LoadingView* loadingView; @property (nonatomic, strong) UIBarButtonItem *selectAllRowsButtonItem; @property (nonatomic, strong) UIBarButtonItem *normalModeRightBarButtonItem; -@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; @end @implementation BaseTableViewController @@ -438,7 +437,7 @@ - (void)showLoadingView self.navigationController.navigationBar.userInteractionEnabled = NO; self.navigationController.toolbar.userInteractionEnabled = NO; self.navigationController.interactivePopGestureRecognizer.enabled = NO; - [self showPlaceHolder:NO]; + //[self showPlaceHolder:NO]; [self.loadingView show]; } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h index 3bfd0b3846..9d6a7e19a5 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h @@ -26,17 +26,27 @@ @class SpriteObject; @class Brick; @class Look; + +@protocol EnableAndDisableSegmentedControllDelegate +- (void)enableSegmentedControll; +- (void)disableSegmentedControll; +@end + @protocol BrickLookProtocol; @protocol PaintDelegate - (void)addPaintedImage:(UIImage *)image andPath:(NSString *)path; - (void)addMediaLibraryLoadedImage:(UIImage*)image withName:(NSString *)name; +- (void)addLookAction:(id)sender; +- (void)initNavigationBar; @end @interface LooksTableViewController : BaseTableViewController @property (strong, nonatomic) SpriteObject *object; +@property (weak, nonatomic) id segmentedControllDelegate; +@property (weak, nonatomic) UIViewController *parentNavigationController; @property (nonatomic) BOOL showAddLookActionSheetAtStartForScriptEditor; @property (nonatomic) BOOL showAddLookActionSheetAtStartForObject; @property (copy) void (^afterSafeBlock)(Look* look); diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m index 7d6e67b3fd..d26b55a756 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m @@ -55,7 +55,7 @@ @implementation LooksTableViewController - (void)initNavigationBar { UIBarButtonItem *editButtonItem = [TableUtil editButtonItemWithTarget:self action:@selector(editAction:)]; - self.navigationItem.rightBarButtonItem = editButtonItem; + self.parentNavigationController.navigationItem.rightBarButtonItem = editButtonItem; [self changeEditingBarButtonState]; } @@ -88,12 +88,12 @@ - (void)viewDidLoad - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self reloadData]; } #pragma mark - actions - (void)editAction:(id)sender { + [self.tableView setEditing:false animated:YES]; NSString *actionSheetTitle = self.object.isBackground ? kLocalizedEditBackgrounds : kLocalizedEditLooks; @@ -104,24 +104,27 @@ - (void)editAction:(id)sender NSString *destructiveActionTitle = self.object.isBackground ? kLocalizedDeleteBackgrounds : kLocalizedDeleteLooks; [[actionSheet addDestructiveActionWithTitle:destructiveActionTitle handler:^{ + [self.segmentedControllDelegate disableSegmentedControll]; self.deletionMode = YES; self.copyMode = NO; [self setupEditingToolBar]; - [super changeToEditingMode:sender]; + [self changeToEditingMode:sender]; }] addDefaultActionWithTitle:kLocalizedCopyLooks handler:^{ + [self.segmentedControllDelegate disableSegmentedControll]; self.deletionMode = NO; self.copyMode = YES; [self setupEditingToolBar]; - [super changeToEditingMode:sender]; + [self changeToEditingMode:sender]; }]; } if (self.object.lookList.count >= 2) { [actionSheet addDefaultActionWithTitle:kLocalizedMoveLooks handler:^{ + [self.segmentedControllDelegate disableSegmentedControll]; self.deletionMode = NO; self.copyMode = NO; - [super changeToMoveMode:sender]; + [self changeToMoveMode:sender]; }]; } @@ -133,6 +136,46 @@ - (void)editAction:(id)sender showWithController:self]; } +- (void)changeToMoveMode:(id)sender +{ + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedDone + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = NO; + self.parentNavigationController.navigationController.toolbar.hidden = true; + self.editing = YES; +} + +- (void)changeToEditingMode:(id)sender +{ + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = YES; + self.editing = YES; +} + +- (void)exitEditingMode +{ + self.parentNavigationController.navigationItem.hidesBackButton = NO; + [self initNavigationBar]; + [self.tableView setEditing:NO animated:YES]; + [self setupToolBar]; + self.editing = NO; + [self.segmentedControllDelegate enableSegmentedControll]; + self.parentNavigationController.navigationController.toolbar.hidden = false; +} + - (void)toggleDetailCellsMode { self.useDetailCells = !self.useDetailCells; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; @@ -189,7 +232,7 @@ - (void)copySelectedLooksAction:(id)sender NSArray *selectedRowsIndexPaths = [self.tableView indexPathsForSelectedRows]; if (! [selectedRowsIndexPaths count]) { // nothing selected, nothing to delete... - [super exitEditingMode]; + [self exitEditingMode]; return; } @@ -199,7 +242,7 @@ - (void)copySelectedLooksAction:(id)sender [looksToCopy addObject:look]; } [self copyLooksActionWithSourceLooks:looksToCopy]; - [super exitEditingMode]; + [self exitEditingMode]; } - (void)copyLooksActionWithSourceLooks:(NSArray *)sourceLooks @@ -242,7 +285,7 @@ - (void)confirmDeleteSelectedLooksAction:(id)sender NSArray *selectedRowsIndexPaths = [self.tableView indexPathsForSelectedRows]; if (! [selectedRowsIndexPaths count]) { // nothing selected, nothing to delete... - [super exitEditingMode]; + [self exitEditingMode]; return; } [self deleteSelectedLooksAction]; @@ -259,7 +302,7 @@ - (void)deleteSelectedLooksAction [self.dataCache removeObjectForKey:look.fileName]; } [self.object removeLooks:looksToRemove AndSaveToDisk:YES]; - [super exitEditingMode]; + [self exitEditingMode]; [self.tableView deleteRowsAtIndexPaths:selectedRowsIndexPaths withRowAnimation:UITableViewRowAnimationNone]; [self showPlaceHolder:(! (BOOL)[self.object.lookList count])]; [self hideLoadingView]; @@ -304,6 +347,7 @@ - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS return cell; } + CatrobatBaseCell* imageCell = (CatrobatBaseCell*)cell; Look *look = [self.object.lookList objectAtIndex:indexPath.row]; imageCell.iconImageView.image = nil; @@ -694,7 +738,7 @@ - (void)setupToolBar UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; - self.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; + self.parentNavigationController.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; } - (void)setupEditingToolBar @@ -716,7 +760,7 @@ - (void)setupEditingToolBar UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; - self.toolbarItems = [NSArray arrayWithObjects:self.selectAllRowsButtonItem, flex, editActionButton, nil]; + self.parentNavigationController.toolbarItems = [NSArray arrayWithObjects:self.selectAllRowsButtonItem, flex, editActionButton, nil]; } #pragma mark paintDelegate @@ -872,9 +916,9 @@ - (BOOL)checkUserAuthorisation:(UIImagePickerControllerSourceType)pickerType - (void)changeEditingBarButtonState { if (self.object.lookList.count >= 1) { - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentViewController.navigationItem.rightBarButtonItem.enabled = YES; } else { - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentViewController.navigationItem.rightBarButtonItem.enabled = NO; } } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h index 95ed4b6fe1..50f43236d3 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h @@ -24,11 +24,19 @@ #import "BaseCollectionViewController.h" @class SpriteObject; +@protocol EnableAndDisableSegmentedControllDelegate; @interface ScriptCollectionViewController : BaseCollectionViewController @property (nonatomic, strong) SpriteObject *object; +@property (nonatomic, strong) UIViewController *parentNavigationController; +@property (weak, nonatomic) id segmentedControllDelegate; + - (void)removeBrickOrScript:(id)scriptOrBrick atIndexPath:(NSIndexPath*)indexPath; +-(void)turnOnInsertingBrickMode; +-(void)reloadData; +- (void)showBrickPickerAction:(id)sender; +- (void)changeDeleteBarButtonState; @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m index f45a73fc22..c23d5c6c90 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m @@ -114,6 +114,7 @@ - (void)viewDidLoad - (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; // do not call super to prevent automatic scrolling when opening a UIPickerView @@ -369,6 +370,7 @@ - (void)deleteAlertView addDefaultActionWithTitle:kLocalizedYes handler:^{ [self deleteSelectedBricks]; self.allBricksSelected = NO; + [self.segmentedControllDelegate enableSegmentedControll]; }] build] showWithController:self]; } @@ -789,6 +791,7 @@ -(void)deleteSelectedBricks -(void)turnOnInsertingBrickMode { + NSLog(@"@%ss","turn on"); [[BrickInsertManager sharedInstance] setBrickInsertionMode:YES]; for (UIButton *button in self.navigationController.toolbar.items) { button.enabled = NO; @@ -797,7 +800,7 @@ -(void)turnOnInsertingBrickMode layout.longPressGestureRecognizer.minimumPressDuration = 0.1; [self.navigationItem setHidesBackButton:YES animated:NO]; dispatch_async(dispatch_get_main_queue(), ^{ - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; }); } @@ -812,7 +815,7 @@ -(void)turnOffInsertingBrickMode layout.longPressGestureRecognizer.minimumPressDuration = 0.5; [self.navigationItem setHidesBackButton:NO animated:NO]; dispatch_async(dispatch_get_main_queue(), ^{ - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; }); } @@ -824,11 +827,11 @@ - (void)changeDeleteBarButtonState } else { navBarButton= [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel style:UIBarButtonItemStylePlain target:self action:@selector(exitDeleteMode)]; } - self.navigationItem.rightBarButtonItem = navBarButton; + self.parentNavigationController.navigationItem.rightBarButtonItem = navBarButton; if (self.object.scriptList.count) { - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; } else { - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; } } @@ -1178,6 +1181,7 @@ -(void)enableUserInteractionAndResetHighlight for (BrickCell *cell in self.collectionView.visibleCells) { cell.enabled = YES; cell.alpha = kBrickCellActiveOpacity; + [self.segmentedControllDelegate enableSegmentedControll]; } CGFloat maxContentOffset = self.collectionView.contentSize.height + self.collectionView.contentInset.bottom - self.collectionView.bounds.size.height; @@ -1197,17 +1201,18 @@ -(void)disableUserInteractionAndHighlight:(BrickCell*)brickCell withMarginBottom collectionViewLayout.longPressGestureRecognizer.enabled = NO; self.collectionView.scrollEnabled = NO; self.isEditingBrickMode = YES; - self.navigationController.toolbar.userInteractionEnabled = NO; - self.navigationController.navigationBar.userInteractionEnabled = NO; + self.parentNavigationController.navigationController.toolbar.userInteractionEnabled = NO; + self.parentNavigationController.navigationController.navigationBar.userInteractionEnabled = NO; // disable swipe back gesture - if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { - self.navigationController.interactivePopGestureRecognizer.enabled = NO; + if ([self.parentNavigationController.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { + self.parentNavigationController.navigationController.interactivePopGestureRecognizer.enabled = NO; } for (BrickCell *cell in self.collectionView.visibleCells) { if (cell != brickCell) { cell.enabled = NO; cell.alpha = kBrickCellInactiveWhileEditingOpacity; + [self.segmentedControllDelegate disableSegmentedControll]; } } @@ -1292,8 +1297,9 @@ - (void)selectAllRows:(id)sender -(void)enterDeleteMode { + [self.segmentedControllDelegate disableSegmentedControll]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel style:UIBarButtonItemStylePlain target:self action:@selector(exitDeleteMode)]; - self.navigationItem.rightBarButtonItem = cancelButton; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; [UIView animateWithDuration:0.5f delay:0.0f usingSpringWithDamping:0.6f initialSpringVelocity:1.5f options:UIViewAnimationOptionCurveEaseInOut animations:^{ for (BrickCell *brickCell in self.collectionView.visibleCells) { @@ -1311,7 +1317,7 @@ -(void)enterDeleteMode -(void)exitDeleteMode { UIBarButtonItem *deleteButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedDelete style:UIBarButtonItemStylePlain target:self action:@selector(enterDeleteMode)]; - self.navigationItem.rightBarButtonItem = deleteButton; + self.parentNavigationController.navigationItem.rightBarButtonItem = deleteButton; [UIView animateWithDuration:0.3f delay:0.0f usingSpringWithDamping:0.65f initialSpringVelocity:0.5f options:UIViewAnimationOptionCurveEaseInOut animations:^{ @@ -1334,6 +1340,7 @@ -(void)exitDeleteMode }]; self.editing = NO; self.allBricksSelected = NO; + [self.segmentedControllDelegate enableSegmentedControll]; } -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer @@ -1341,4 +1348,22 @@ -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer return NO; } +- (void)setupToolBar +{ + [super setupToolBar]; + +// UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd +// target:self +// action:@selector(showBrickPickerAction:)]; +// UIBarButtonItem *play = [[PlayButton alloc] initWithTarget:self +// action:@selector(playSceneAction:)]; +// UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace +// target:self +// action:nil]; +// self.parentNavigationController.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; + + + self.parentNavigationController.toolbarItems = self.toolbarItems; +} + @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h index 463d3465e0..3c5a8803f0 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h @@ -25,9 +25,11 @@ @class SpriteObject; @class Sound; +@protocol EnableAndDisableSegmentedControllDelegate; @protocol SoundDelegate - (void)addSound:(Sound *)sound; +- (void)initNavigationBar; @end @@ -35,6 +37,11 @@ @property (strong, nonatomic) SpriteObject *object; @property (nonatomic) BOOL showAddSoundActionSheetAtStart; +@property (weak, nonatomic) id segmentedControllDelegate; +@property (nonatomic, strong) UIViewController *parentNavigationController; @property (copy) void (^afterSafeBlock)(Sound* look); +- (void)playSceneAction:(id)sender; +- (void)addSoundAction:(id)sender; + @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m index 057937465a..c7e7d165ab 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m @@ -51,7 +51,7 @@ @implementation SoundsTableViewController - (void)initNavigationBar { UIBarButtonItem *editButtonItem = [TableUtil editButtonItemWithTarget:self action:@selector(editAction:)]; - self.navigationItem.rightBarButtonItem = editButtonItem; + self.parentNavigationController.navigationItem.rightBarButtonItem = editButtonItem; } #pragma mark - events @@ -68,7 +68,8 @@ - (void)viewDidLoad self.currentPlayingSong = nil; self.currentPlayingSongCell = nil; self.placeHolderView.title = kLocalizedTapPlusToAddSound; - [self showPlaceHolder:(! (BOOL)[self.object.soundList count])]; + //[self showPlaceHolder:(! (BOOL)[self.object.soundList count])]; + self.placeHolderView.hidden = (self.object.soundList.count != 0); [self setupToolBar]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; self.isAllowed = YES; @@ -76,6 +77,7 @@ - (void)viewDidLoad if(self.showAddSoundActionSheetAtStart) { [self addSoundAction:nil]; } + } - (void)viewWillAppear:(BOOL)animated @@ -83,6 +85,7 @@ - (void)viewWillAppear:(BOOL)animated [super viewWillAppear:animated]; [self.navigationController setToolbarHidden:NO]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; + } - (void)viewWillDisappear:(BOOL)animated @@ -109,14 +112,14 @@ - (void)editAction:(id)sender [actionSheet addDestructiveActionWithTitle:kLocalizedDeleteSounds handler:^{ self.deletionMode = YES; [self setupEditingToolBar]; - [super changeToEditingMode:sender]; + [self changeToEditingMode:sender]; }]; } if (self.object.soundList.count >= 2) { [actionSheet addDefaultActionWithTitle:kLocalizedMoveSounds handler:^{ self.deletionMode = NO; - [super changeToMoveMode:sender]; + [self changeToMoveMode:sender]; }]; } @@ -219,7 +222,7 @@ - (void)confirmDeleteSelectedSoundsAction:(id)sender NSArray *selectedRowsIndexPaths = [self.tableView indexPathsForSelectedRows]; if (! [selectedRowsIndexPaths count]) { // nothing selected, nothing to delete... - [super exitEditingMode]; + [self exitEditingMode]; return; } self.deletionMode = NO; @@ -237,7 +240,7 @@ - (void)deleteSelectedSoundsAction [soundsToRemove addObject:sound]; } [self.object removeSounds:soundsToRemove AndSaveToDisk:YES]; - [super exitEditingMode]; + [self exitEditingMode]; [self.tableView deleteRowsAtIndexPaths:selectedRowsIndexPaths withRowAnimation:UITableViewRowAnimationNone]; [super showPlaceHolder:(! (BOOL)[self.object.soundList count])]; [self hideLoadingView]; @@ -582,10 +585,48 @@ - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)fl } } +- (void)changeToMoveMode:(id)sender +{ + [self.segmentedControllDelegate disableSegmentedControll]; + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedDone + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = NO; + self.parentNavigationController.navigationController.toolbar.hidden = true; + self.editing = YES; +} + +- (void)changeToEditingMode:(id)sender +{ + [self.segmentedControllDelegate disableSegmentedControll]; + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = YES; + self.editing = YES; +} + - (void)exitEditingMode { [super exitEditingMode]; self.deletionMode = NO; + self.parentNavigationController.navigationItem.hidesBackButton = NO; + [self initNavigationBar]; + self.parentNavigationController.navigationController.toolbar.hidden = false; + [self.tableView setEditing:NO animated:YES]; + [self setupToolBar]; + self.editing = NO; + [self.segmentedControllDelegate enableSegmentedControll]; } #pragma mark - Helper Methods @@ -675,6 +716,7 @@ - (void)setupToolBar target:self action:nil]; self.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; + self.parentNavigationController.toolbarItems = self.toolbarItems; } - (void)setupEditingToolBar @@ -689,14 +731,15 @@ - (void)setupEditingToolBar target:self action:nil]; self.toolbarItems = [NSArray arrayWithObjects:self.selectAllRowsButtonItem, flex, deleteButton, nil]; + self.parentNavigationController.toolbarItems = self.toolbarItems; } - (void)changeEditingBarButtonState { if (self.object.soundList.count >= 1) { - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; } else { - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; } } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h deleted file mode 100644 index d93e096cab..0000000000 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2010-2023 The Catrobat Team - * (http://developer.catrobat.org/credits) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * (http://developer.catrobat.org/license_additional_term) - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#import -#import "BaseTableViewController.h" - -@class SpriteObject; - -@interface ObjectTableViewController : BaseTableViewController -@property (strong, nonatomic) SpriteObject *object; -@end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m deleted file mode 100644 index becb719e72..0000000000 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright (C) 2010-2023 The Catrobat Team - * (http://developer.catrobat.org/credits) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * (http://developer.catrobat.org/license_additional_term) - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#import "ObjectTableViewController.h" -#import "ScriptCollectionViewController.h" -#import "LooksTableViewController.h" -#import "SoundsTableViewController.h" -#import "SegueDefines.h" -#import "TableUtil.h" -#import "CatrobatImageCell.h" -#import "Util.h" -#import "Pocket_Code-Swift.h" - -@interface ObjectTableViewController () - -@end - -@implementation ObjectTableViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - self.title = self.object.name; - self.navigationItem.title = self.object.name; - [self setupToolBar]; - self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; -} - -#pragma mark - Table view data source -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 1; -} - -- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section -{ - return 3; -} - -- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath -{ - static NSString *CellIdentifier = @"MenuCell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; - - if ([cell conformsToProtocol:@protocol(CatrobatImageCell)]) { - UITableViewCell *imageCell = (UITableViewCell*)cell; - switch (indexPath.row) { - case 0: - imageCell.iconImageView.image = [UIImage imageNamed:@"catrobat.scripts"]; - imageCell.titleLabel.text = kLocalizedScripts; - break; - case 1: - imageCell.iconImageView.image = [UIImage imageNamed:@"eye.fill"]; - imageCell.titleLabel.text = (self.object.isBackground - ? kLocalizedBackgrounds - : kLocalizedLooks); - break; - case 2: - imageCell.iconImageView.image = [UIImage imageNamed:@"speaker.wave.2.fill"]; - imageCell.titleLabel.text = kLocalizedSounds; - break; - } - - imageCell.iconImageView.contentMode = UIViewContentModeScaleAspectFit; - imageCell.iconImageView.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; - } - return cell; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return [TableUtil heightForImageCell]; -} - -#pragma mark - table view delegates -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Pass the selected object to the new view controller - static NSString *toScriptsSegueID = kSegueToScripts; - static NSString *toLooksSegueID = kSegueToLooks; - static NSString *toSoundsSegueID = kSegueToSounds; - - UITableViewCell* sender = [tableView cellForRowAtIndexPath:indexPath]; - if (indexPath.row == 0) - [self performSegueWithIdentifier:toScriptsSegueID sender:sender]; - else if (indexPath.row == 1) - [self performSegueWithIdentifier:toLooksSegueID sender:sender]; - else if (indexPath.row == 2) - [self performSegueWithIdentifier:toSoundsSegueID sender:sender]; - - [tableView deselectRowAtIndexPath:indexPath animated:YES]; -} - -#pragma mark - segue handlers -- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender -{ - // Pass the selected object to the new view controller. - static NSString *toScriptsSegueID = kSegueToScripts; - static NSString *toLooksSegueID = kSegueToLooks; - static NSString *toSoundsSegueID = kSegueToSounds; - - UIViewController* destController = segue.destinationViewController; - if ([sender isKindOfClass:[UITableViewCell class]]) { - if (([segue.identifier isEqualToString:toScriptsSegueID] || - [segue.identifier isEqualToString:toLooksSegueID] || - [segue.identifier isEqualToString:toSoundsSegueID]) && - [destController respondsToSelector:@selector(setObject:)]) { - [destController performSelector:@selector(setObject:) withObject:self.object]; - } - } -} - -#pragma mark - helpers -- (void)setupToolBar -{ - [super setupToolBar]; - - UIBarButtonItem *play = [[PlayButton alloc] initWithTarget:self - action:@selector(playSceneAction:)]; - UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace - target:self - action:nil]; - self.toolbarItems = [NSArray arrayWithObjects: flex, play, flex, nil]; -} - -@end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift new file mode 100644 index 0000000000..67ce26ad3f --- /dev/null +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift @@ -0,0 +1,152 @@ +/** + * Copyright (C) 2010-2023 The Catrobat Team + * (http://developer.catrobat.org/credits) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * An additional term exception under section 7 of the GNU Affero + * General Public License, version 3, is available at + * (http://developer.catrobat.org/license_additional_term) + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +import UIKit + +class ObjectViewController: UIViewController, EnableAndDisableSegmentedControllDelegate { + + @IBOutlet private weak var objectSegmentedControl: UISegmentedControl! + @IBOutlet private weak var soundsContainerView: UIView! + @IBOutlet private weak var scriptsContainerView: UIView! + @IBOutlet private weak var looksContainerView: UIView! + public var object: SpriteObject? + + var soundsViewController: SoundsTableViewController? + var looksViewController: LooksTableViewController? + var scriptsViewController: ScriptCollectionViewController? + + override func viewDidLoad() { + super.viewDidLoad() + configureSegmentedControll() + scriptsContainerView.isHidden = true + + if let object = object { + self.title = object.name + self.navigationItem.title = object.name + } + let leftSwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGesture(_:))) + leftSwipeGestureRecognizer.direction = .left + objectSegmentedControl.addGestureRecognizer(leftSwipeGestureRecognizer) + + let rightSwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGesture(_:))) + rightSwipeGestureRecognizer.direction = .right + objectSegmentedControl.addGestureRecognizer(rightSwipeGestureRecognizer) + + navigationController?.setToolbarHidden(false, animated: true) + showScripts() + } + + // TODO There is a bug, sometimes if you swipe, the text color of the selected segment does not get adjusted + + @objc func handleSwipeGesture(_ gesture: UISwipeGestureRecognizer) { + if gesture.direction == .left { + if objectSegmentedControl.selectedSegmentIndex < 2 { + objectSegmentedControl.selectedSegmentIndex += 1 + } + } else if gesture.direction == .right { + if objectSegmentedControl.selectedSegmentIndex > 0 { + objectSegmentedControl.selectedSegmentIndex -= 1 + } + } + objectSegmentedControl.sendActions(for: .valueChanged) + } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "toLooks" { + let destVC = segue.destination as! LooksTableViewController + destVC.object = object + destVC.segmentedControllDelegate = self + destVC.parentNavigationController = self + looksViewController = destVC + } else if segue.identifier == "toSounds" { + let destVC = segue.destination as! SoundsTableViewController + destVC.object = object + destVC.segmentedControllDelegate = self + destVC.parentNavigationController = self + soundsViewController = destVC + } else if segue.identifier == "toScripts" { + let destVC = segue.destination as! ScriptCollectionViewController + destVC.object = object + destVC.segmentedControllDelegate = self + destVC.parentNavigationController = self + scriptsViewController = destVC + } + } + + func configureSegmentedControll() { + + self.objectSegmentedControl.setTitle(kLocalizedScripts, forSegmentAt: 0) + self.objectSegmentedControl.setTitle(kLocalizedBackgrounds, forSegmentAt: 1) + self.objectSegmentedControl.setTitle(kLocalizedSounds, forSegmentAt: 2) + } + + @IBAction private func segmentTapped(_ sender: UISegmentedControl) { + + switch sender.selectedSegmentIndex { + case 0: + showScripts() + case 1: + showBackgrounds() + case 2: + showSounds() + default: + break + } + } + + @objc func setObject(_ object: SpriteObject) { + self.object = object + } + + func showBackgrounds() { + scriptsContainerView.isHidden = true + looksContainerView.isHidden = false + soundsContainerView.isHidden = true + looksViewController?.initNavigationBar() + looksViewController?.setupToolBar() + } + + func showScripts() { + scriptsContainerView.isHidden = false + looksContainerView.isHidden = true + soundsContainerView.isHidden = true + scriptsViewController?.setupToolBar() + scriptsViewController?.changeDeleteBarButtonState() + } + + func showSounds() { + scriptsContainerView.isHidden = true + looksContainerView.isHidden = true + soundsContainerView.isHidden = false + soundsViewController?.initNavigationBar() + soundsViewController?.setupToolBar() + } + + func enableSegmentedControll() { + objectSegmentedControl.isEnabled = true + } + + func disableSegmentedControll() { + objectSegmentedControl.isEnabled = false + } + +} diff --git a/src/Catty/ViewController/Continue&New/SceneTableViewController.m b/src/Catty/ViewController/Continue&New/SceneTableViewController.m index 692d20c111..34bdc3653f 100644 --- a/src/Catty/ViewController/Continue&New/SceneTableViewController.m +++ b/src/Catty/ViewController/Continue&New/SceneTableViewController.m @@ -22,7 +22,6 @@ #import "SceneTableViewController.h" #import "TableUtil.h" -#import "ObjectTableViewController.h" #import "SegueDefines.h" #import "Brick.h" #import "CatrobatImageCell.h" @@ -632,10 +631,13 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender UITableViewCell *cell = (UITableViewCell*) sender; NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; if ([segue.identifier isEqualToString:toObjectSegueID]) { - if ([destController isKindOfClass:[ObjectTableViewController class]]) { - ObjectTableViewController *tvc = (ObjectTableViewController*) destController; + if ([destController isKindOfClass:[ObjectViewController class]]) { + ObjectViewController *tvc = (ObjectViewController*) destController; + if ([tvc respondsToSelector:@selector(setObject:)]) { SpriteObject* object = [self.scene.objects objectAtIndex:(kBackgroundObjectIndex + indexPath.section + indexPath.row)]; + //tvc.title = object.name; + //tvc.navigationItem.title = object.name; [destController performSelector:@selector(setObject:) withObject:object]; } } diff --git a/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift b/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift index 19f3d7d2a2..dd8d879c77 100644 --- a/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift +++ b/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift @@ -24,7 +24,7 @@ import BluetoothHelper import CoreBluetooth import UIKit -@objc extension StagePresenterViewController { +@objc public extension StagePresenterViewController { @objc(checkResourcesAndPushViewControllerTo:completion:) func checkResourcesAndPushViewController(to navigationController: UINavigationController, completion: @escaping () -> Void = {}) {