- widget tool improvements

- tool box constraint fixes
This commit is contained in:
TrueZhuanjia
2025-06-22 15:57:29 +08:00
parent 9937b67509
commit cd6e08956c
8 changed files with 153 additions and 36 deletions
@@ -78,6 +78,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) IBOutlet UISegmentedControl *vibrationStyleSelector;
@property (strong, nonatomic) IBOutlet UIStackView *vibrationStyleStack;
@property (strong, nonatomic) IBOutlet UILabel *loadConfigTipLabel;
@@ -169,7 +169,7 @@
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(setControllerCALayerSliderValues:)
selector:@selector(legacyOscLayerTapped:)
name:@"LegacyOscCALayerSelectedNotification"
object:nil];
@@ -624,10 +624,20 @@
if([self isIPhone]) [self updateClippedMaskForView:view];
}
- (void)enableCommonWidgetTools{
self.loadConfigTipLabel.hidden = YES;
self.widgetSizeStack.hidden = NO;
self.widgetHeightStack.hidden = NO;
self.borderWidthAlphaStack.hidden = NO;
if([self isIPhone]) self.vibrationStyleStack.hidden = NO;
}
- (void)widgetViewTapped: (NSNotification *)notification{
//self.undoButton.alpha = selectedWidgetView.layoutChanges.count>1 && !CGPointEqualToPoint(selectedWidgetView.layoutChanges.lastObject.CGPointValue, selectedWidgetView.initialCenter)? 1.0 : 0.3;
// receive the selected widgetView obj passed from the notification
[self enableCommonWidgetTools];
OnScreenWidgetView* widgetView = (OnScreenWidgetView* )notification.object;
@@ -676,8 +686,8 @@
}
}
- (void)setControllerCALayerSliderValues: (NSNotification *)notification{
// receive the selected widgetView obj passed from the notification
- (void)legacyOscLayerTapped: (NSNotification *)notification{
[self enableCommonWidgetTools];
CALayer* controllerLayer = (CALayer* )notification.object;
[self->selectedWidgetView.stickBallLayer removeFromSuperlayer];
[self->selectedWidgetView.crossMarkLayer removeFromSuperlayer];
@@ -705,6 +715,7 @@
NSNumber *style = [OnScreenControls.layerVibrationStyleDic objectForKey:selectedControllerLayer.name];
self.vibrationStyleSelector.selectedSegmentIndex = [style unsignedCharValue];
}
[self autoFitView:_widgetPanelStack];
}
- (void)widgetSizeSliderMoved:(UISlider* )sender{
@@ -821,6 +832,8 @@
- (void)setupWidgetPanel{
//[self handleMissingToolBarIcon];
self.widgetPanelStack.hidden = NO;
self.loadConfigTipLabel.hidden = NO;
self.widgetPanelStack.layoutMargins = UIEdgeInsetsMake(10, 10, 10, 10);
self.widgetPanelStack.layoutMarginsRelativeArrangement = YES;
self.widgetPanelStack.layer.cornerRadius = 16;
@@ -844,19 +857,19 @@
[self.widgetSizeSlider addTarget:self action:@selector(widgetSizeSliderMoved:) forControlEvents:(UIControlEventValueChanged)];
self.widgetSizeLabel.text = [LocalizationHelper localizedStringForKey:@"Size"];
self.widgetSizeStack.hidden = _quickSwitchEnabled;
self.widgetSizeStack.hidden = YES;
[self.widgetHeightSlider addTarget:self action:@selector(widgetHeightSliderMoved:) forControlEvents:(UIControlEventValueChanged)];
self.widgetHeightLabel.text = [LocalizationHelper localizedStringForKey:@"Height"];
self.widgetHeightStack.hidden = _quickSwitchEnabled;
self.widgetHeightStack.hidden = YES;
[self.widgetAlphaSlider addTarget:self action:@selector(widgetAlphaSliderMoved:) forControlEvents:(UIControlEventValueChanged)];
self.widgetAlphaLabel.text = [LocalizationHelper localizedStringForKey:@"Alpha"];
[self.widgetBorderWidthSlider addTarget:self action:@selector(widgetBorderWidthSliderMoved:) forControlEvents:(UIControlEventValueChanged)];
self.widgetBorderWidthLabel.text = [LocalizationHelper localizedStringForKey:@"Border Width"];
self.borderWidthAlphaStack.hidden = _quickSwitchEnabled;
self.borderWidthAlphaStack.hidden = YES;
[self.sensitivitySlider addTarget:self action:@selector(sensitivitySliderMoved:) forControlEvents:(UIControlEventValueChanged)];
self.sensitivityLabel.text = [LocalizationHelper localizedStringForKey:@"Sensitivity"];
@@ -871,7 +884,7 @@
if([self isIPhone]){
[self.vibrationStyleSelector addTarget:self action:@selector(vibrationStyleChanged:) forControlEvents:(UIControlEventValueChanged)];
self.vibrationStyleStack.hidden = NO;
self.vibrationStyleStack.hidden = YES;
NSDictionary *normalAttributes = @{
NSForegroundColorAttributeName: [UIColor whiteColor]
};
@@ -888,6 +901,8 @@
//frame.origin = CGPointMake(self.view.bounds.size.width/2, 100);
frame.origin = CGPointMake(self.view.bounds.size.width/2-self.widgetPanelStack.frame.size.width/2, 100);
self.widgetPanelStack.frame = frame;
[self autoFitView:self.widgetPanelStack];
if([self isIPhone]) {
@@ -128,7 +128,12 @@
}
- (void)presentCommandManagerViewController{
[self presentViewController:toolBoxViewController animated:YES completion:nil];
toolBoxViewController = [[ToolBoxViewController alloc] init];
toolBoxViewController.specialEntryDelegate = self;
[self configOscLayoutTool];
[self presentViewController:toolBoxViewController animated:YES completion:^{
//[self->toolBoxViewController setupConstraints];
}];
}
- (void)configSwipeGestures{
@@ -31,7 +31,7 @@ import UIKit
"widgetSwitchTool":SwiftLocalizationHelper.localizedString(forKey: "[ Switch among on-screen widget profiles ]"),
"widgetLayoutTool":SwiftLocalizationHelper.localizedString(forKey: "[ Open on-screen widget tool ]")
]
private var viewPinned: Bool = false
private var isEditingMode: Bool = false {
didSet {
@@ -57,10 +57,17 @@ import UIKit
override public func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
setupConstraints()
//setupConstraints()
reloadTableView()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//setupConstraints()
}
private func setupViews() {
// Set corner radius
@@ -76,7 +83,7 @@ import UIKit
view.backgroundColor = viewBackgroundColor
tableView.backgroundColor = .clear
tableView.rowHeight = 60
tableView.rowHeight = isIPhone() ? 47 : 60
tableView.separatorColor = highlightColor
// Configure buttons
addButton.setTitle(SwiftLocalizationHelper.localizedString(forKey: "Add / Duplicate"), for: .normal)
@@ -108,12 +115,23 @@ import UIKit
}
private func setupConstraints() {
public override func updateViewConstraints() {
self.setupConstraints()
super.updateViewConstraints()
}
private func isIPhone()->Bool {
return UIDevice.current.userInterfaceIdiom == .phone
}
@objc public func setupConstraints() {
guard view.superview != nil else {
return
}
NSLayoutConstraint.deactivate(view.constraints)
view.translatesAutoresizingMaskIntoConstraints = false
tableView.translatesAutoresizingMaskIntoConstraints = false
@@ -127,9 +145,13 @@ import UIKit
NSLayoutConstraint.activate([
// Set the width and height of the view
view.widthAnchor.constraint(equalTo: view.superview!.widthAnchor, multiplier: 1),
view.heightAnchor.constraint(equalTo: view.superview!.heightAnchor, multiplier: 1),
view.widthAnchor.constraint(equalTo: view.superview!.widthAnchor, multiplier: isIPhone() ? 0.7 : 0.8),
view.heightAnchor.constraint(equalTo: view.superview!.heightAnchor, multiplier: 0.99),
// Set the width and height of the view
//view.leadingAnchor.constraint(equalTo: view.superview!.leadingAnchor, constant: 60),
//view.trailingAnchor.constraint(equalTo: view.superview!.trailingAnchor, constant: -60),
// Center the view horizontally and vertically
view.centerXAnchor.constraint(equalTo: view.superview!.centerXAnchor),
view.centerYAnchor.constraint(equalTo: view.superview!.centerYAnchor),