- feat: implementation of slidable button

This commit is contained in:
TrueZhuanjia
2025-08-09 22:02:03 +08:00
parent 679c0a2b4c
commit ab503875cb
12 changed files with 384 additions and 31 deletions
+3 -2
View File
@@ -232,12 +232,12 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
}
- (void)keyboardWillShow:(NSNotification *)notification{
NSLog(@"keyboard will show markmark %f", CACurrentMediaTime());
// NSLog(@"keyboard will show markmark %f", CACurrentMediaTime());
if(settings.liftStreamViewForKeyboard && !isInputingText){
NSDictionary *userInfo = notification.userInfo;
// Get the keyboard size from the notification
CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
NSLog(@"keyboard will show markmark, lowest height %f", keyboardToggleRecognizer.lowestTouchPointHeight);
// NSLog(@"keyboard will show markmark, lowest height %f", keyboardToggleRecognizer.lowestTouchPointHeight);
if(keyboardFrame.size.height < CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.25) return; // return in case of abnormal keyboard height
HeightViewLiftedTo = keyboardFrame.size.height - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.1; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing.
if(HeightViewLiftedTo < 0) HeightViewLiftedTo = 0; // set HeightViewLiftedTo to 0 if it is high enough and not going to be covered by keyboard.
@@ -454,6 +454,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
widgetView.trackballDecelerationRate = buttonState.decelerationRate;
widgetView.stickIndicatorOffset = buttonState.stickIndicatorOffset;
widgetView.minStickOffset = buttonState.minStickOffset;
widgetView.isSlidable = buttonState.isSlidable;
// Add the widgetView to the view controller's view
[self->streamFrameTopLayerView addSubview:widgetView]; // add keyboard button to the stream frame view. must add it to the target view before setting location.
buttonState.position = [self denormalizeWidgetPosition:buttonState.position];