Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
e628c036
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
大约 1 年 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e628c036
编写于
4月 16, 2020
作者:
Y
yixiangboy
提交者:
GitHub
4月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #443 from BinaryParadise/master
支持浮窗自动默认停靠(可调用方法修改)和记录上次坐标
上级
41b9108f
1ffa9c67
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
72 addition
and
0 deletion
+72
-0
iOS/DoraemonKit/Src/Core/Entry/View/DoraemonEntryView.h
iOS/DoraemonKit/Src/Core/Entry/View/DoraemonEntryView.h
+5
-0
iOS/DoraemonKit/Src/Core/Entry/View/DoraemonEntryView.m
iOS/DoraemonKit/Src/Core/Entry/View/DoraemonEntryView.m
+59
-0
iOS/DoraemonKit/Src/Core/Manager/DoraemonManager.h
iOS/DoraemonKit/Src/Core/Manager/DoraemonManager.h
+4
-0
iOS/DoraemonKit/Src/Core/Manager/DoraemonManager.m
iOS/DoraemonKit/Src/Core/Manager/DoraemonManager.m
+4
-0
未找到文件。
iOS/DoraemonKit/Src/Core/Entry/View/DoraemonEntryView.h
浏览文件 @
e628c036
...
@@ -8,7 +8,12 @@
...
@@ -8,7 +8,12 @@
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
/// 入口滑动浮窗(默认记录上次坐标)
@interface
DoraemonEntryView
:
UIWindow
@interface
DoraemonEntryView
:
UIWindow
/// 是否自动停靠,默认为YES
@property
(
nonatomic
,
assign
)
BOOL
autoDock
;
// 定制位置
// 定制位置
-
(
instancetype
)
initWithStartPoint
:(
CGPoint
)
startingPosition
;
-
(
instancetype
)
initWithStartPoint
:(
CGPoint
)
startingPosition
;
-
(
void
)
show
;
-
(
void
)
show
;
...
...
iOS/DoraemonKit/Src/Core/Entry/View/DoraemonEntryView.m
浏览文件 @
e628c036
...
@@ -136,6 +136,10 @@
...
@@ -136,6 +136,10 @@
}
}
-
(
void
)
pan
:(
UIPanGestureRecognizer
*
)
sender
{
-
(
void
)
pan
:(
UIPanGestureRecognizer
*
)
sender
{
if
(
self
.
autoDock
)
{
[
self
autoDocking
:
sender
];
return
;
}
//1、获得拖动位移
//1、获得拖动位移
CGPoint
offsetPoint
=
[
sender
translationInView
:
sender
.
view
];
CGPoint
offsetPoint
=
[
sender
translationInView
:
sender
.
view
];
//2、清空拖动位移
//2、清空拖动位移
...
@@ -157,6 +161,61 @@
...
@@ -157,6 +161,61 @@
newY
=
DoraemonScreenHeight
-
_kEntryViewSize
/
2
;
newY
=
DoraemonScreenHeight
-
_kEntryViewSize
/
2
;
}
}
panView
.
center
=
CGPointMake
(
newX
,
newY
);
panView
.
center
=
CGPointMake
(
newX
,
newY
);
[[
NSUserDefaults
standardUserDefaults
]
setObject
:@{
@"x"
:
[
NSNumber
numberWithFloat
:
newX
],
@"y"
:
[
NSNumber
numberWithFloat
:
newY
]
}
forKey
:
@"FloatViewCenterLocation"
];
}
-
(
void
)
autoDocking
:(
UIPanGestureRecognizer
*
)
panGestureRecognizer
{
UIView
*
panView
=
panGestureRecognizer
.
view
;
switch
(
panGestureRecognizer
.
state
)
{
case
UIGestureRecognizerStateBegan
:
case
UIGestureRecognizerStateChanged
:
{
CGPoint
translation
=
[
panGestureRecognizer
translationInView
:
panView
];
[
panGestureRecognizer
setTranslation
:
CGPointZero
inView
:
panView
];
panView
.
center
=
CGPointMake
(
panView
.
center
.
x
+
translation
.
x
,
panView
.
center
.
y
+
translation
.
y
);
}
break
;
case
UIGestureRecognizerStateEnded
:
case
UIGestureRecognizerStateCancelled
:
{
CGPoint
location
=
panView
.
center
;
CGFloat
centerX
;
CGFloat
safeBottom
=
0
;
if
(
@available
(
iOS
11
.
0
,
*
))
{
safeBottom
=
self
.
safeAreaInsets
.
bottom
;
}
CGFloat
centerY
=
MAX
(
MIN
(
location
.
y
,
CGRectGetMaxY
([
UIScreen
mainScreen
].
bounds
)
-
safeBottom
),
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
.
height
);
if
(
location
.
x
>
CGRectGetWidth
([
UIScreen
mainScreen
].
bounds
)
/
2
.
f
)
{
centerX
=
CGRectGetWidth
([
UIScreen
mainScreen
].
bounds
)
-
6
;
}
else
{
centerX
=
6
.
f
;
}
[[
NSUserDefaults
standardUserDefaults
]
setObject
:@{
@"x"
:
[
NSNumber
numberWithFloat
:
centerX
],
@"y"
:
[
NSNumber
numberWithFloat
:
centerY
]
}
forKey
:
@"FloatViewCenterLocation"
];
[
UIView
animateWithDuration
:
0
.
3
animations
:
^
{
panView
.
center
=
CGPointMake
(
centerX
,
centerY
);
}];
}
default:
break
;
}
}
-
(
void
)
setAutoDock
:(
BOOL
)
autoDock
{
_autoDock
=
autoDock
;
NSDictionary
*
dict
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"FloatViewCenterLocation"
];
if
(
dict
&&
dict
[
@"x"
]
&&
dict
[
@"y"
])
{
self
.
center
=
CGPointMake
([
dict
[
@"x"
]
integerValue
],
[
dict
[
@"y"
]
integerValue
]);
}
}
}
@end
@end
iOS/DoraemonKit/Src/Core/Manager/DoraemonManager.h
浏览文件 @
e628c036
...
@@ -120,6 +120,10 @@ typedef NS_ENUM(NSUInteger, DoraemonManagerPluginType) {
...
@@ -120,6 +120,10 @@ typedef NS_ENUM(NSUInteger, DoraemonManagerPluginType) {
-
(
void
)
installWithCustomBlock
:(
void
(
^
)(
void
))
customBlock
;
-
(
void
)
installWithCustomBlock
:(
void
(
^
)(
void
))
customBlock
;
/// 设置是否自动停靠屏幕边缘
/// @param autoDock bool
-
(
void
)
setAutoDock
:(
BOOL
)
autoDock
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
dataArray
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
dataArray
;
@property
(
nonatomic
,
copy
)
DoraemonH5DoorBlock
h5DoorBlock
;
@property
(
nonatomic
,
copy
)
DoraemonH5DoorBlock
h5DoorBlock
;
...
...
iOS/DoraemonKit/Src/Core/Manager/DoraemonManager.m
浏览文件 @
e628c036
...
@@ -102,6 +102,7 @@ typedef void (^DoraemonPerformanceBlock)(NSDictionary *);
...
@@ -102,6 +102,7 @@ typedef void (^DoraemonPerformanceBlock)(NSDictionary *);
[
self
installWithCustomBlock
:
^
{
[
self
installWithCustomBlock
:
^
{
//什么也没发生
//什么也没发生
}];
}];
[
self
setAutoDock
:
YES
];
}
}
-
(
void
)
installWithCustomBlock
:(
void
(
^
)(
void
))
customBlock
{
-
(
void
)
installWithCustomBlock
:(
void
(
^
)(
void
))
customBlock
{
...
@@ -191,6 +192,9 @@ typedef void (^DoraemonPerformanceBlock)(NSDictionary *);
...
@@ -191,6 +192,9 @@ typedef void (^DoraemonPerformanceBlock)(NSDictionary *);
}
}
-
(
void
)
setAutoDock
:(
BOOL
)
autoDock
{
self
.
entryView
.
autoDock
=
autoDock
;
}
/**
/**
初始化内置工具数据
初始化内置工具数据
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录