| | |
| | | //视图比例(相对于 main 尺寸) |
| | | @Published var viewRate = 0.5 |
| | | //位置 |
| | | @Published var position:CGSize = CGSize(width: 0, height: 0) |
| | | @Published var position:CGPoint = CGPoint(x: 0, y: 0) |
| | | //主选框位置 |
| | | @Published var mainPosition:CGSize = CGSize(width: 0, height: 0) |
| | | //main 尺寸 |
| | |
| | | BottomBtns().background(Color.black.opacity(0.4)).frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .bottom) |
| | | |
| | | }.background(Color.blue).frame(width:width,height:height) |
| | | .offset(self.miniData.position) |
| | | .position(self.miniData.position) |
| | | .gesture(SimultaneousGesture(DragGesture(minimumDistance: 0) |
| | | .onChanged{ val in |
| | | let x = self.miniData.position.width |
| | | let y = self.miniData.position.height |
| | | let x = self.miniData.position.x |
| | | let y = self.miniData.position.y |
| | | let newX = x - lastLocation.width + val.translation.width; |
| | | let newY = y - lastLocation.height + val.translation.height; |
| | | self.miniData.position = CGSize(width: newX, height: newY) |
| | | self.miniData.position = CGPoint(x: newX, y: newY) |
| | | //print(" onChanged \(index) \(self.miniData.position) ") |
| | | lastLocation = val.translation; |
| | | }.onEnded{ val in |
| | | let x = self.miniData.position.width |
| | | let y = self.miniData.position.height |
| | | let x = self.miniData.position.x |
| | | let y = self.miniData.position.y |
| | | let newX = x - lastLocation.width + val.translation.width; |
| | | let newY = y - lastLocation.height + val.translation.height; |
| | | self.miniData.position = CGSize(width: newX, height: newY) |
| | | self.miniData.position = CGPoint(x: newX, y: newY) |
| | | //print(" onChanged \(index) \(self.miniData.position) ") |
| | | lastLocation = CGSize(width: 0, height: 0); |
| | | //print(" onEnded \(val)") |
| | |
| | | if(miniData.viewRate < 0.4){ |
| | | miniData.viewRate = 0.4 |
| | | }else{ |
| | | var w = miniData.mainSize.width * l / 2 |
| | | self.miniData.position = CGSize(width: self.miniData.position.width - w , height: self.miniData.position.height - w) |
| | | } |
| | | } |
| | | lastZoom = val.magnification; |
| | |
| | | if(miniData.viewRate < 0.4){ |
| | | miniData.viewRate = 0.4 |
| | | }else{ |
| | | var w = miniData.mainSize.width * l / 2 |
| | | self.miniData.position = CGSize(width: self.miniData.position.width - w , height: self.miniData.position.height - w) |
| | | } |
| | | lastZoom = 0; |
| | | })) |
| | | .onAppear{ |
| | | |
| | | print("onAppear body width = \(width) , height = \(height)") |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | .padding(EdgeInsets(top: 5, leading: 15, bottom: 5, trailing: 15)) |
| | | } |
| | | |
| | | func IconButton(info:IconInfo,action:@escaping ()->Void = {},width:CGFloat = 20,height:CGFloat = 20) -> some View{ |
| | | func IconButton(info:IconInfo,action:@escaping ()->Void = {},width:CGFloat = 20,height:CGFloat = 20, disabled:Bool = true,allow:Bool = true) -> some View{ |
| | | Button(action:{ |
| | | print("IconButton ") |
| | | action() |