Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
bdad3901
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,发现更多精彩内容 >>
提交
bdad3901
编写于
4月 01, 2019
作者:
Y
yixiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
沙盒浏览器支持数据库表的本地预览
上级
ac4dbfc9
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
400 addition
and
25 deletion
+400
-25
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/Util/DoraemonDBManager.h
...raemonKit/Src/Core/Plugin/Sanbox/Util/DoraemonDBManager.h
+1
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/Util/DoraemonDBManager.m
...raemonKit/Src/Core/Plugin/Sanbox/Util/DoraemonDBManager.m
+56
-1
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBCell.h
...DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBCell.h
+21
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBCell.m
...DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBCell.m
+35
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBRowView.h
...aemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBRowView.h
+34
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBRowView.m
...aemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBRowView.m
+63
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBShowView.h
...emonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBShowView.h
+18
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBShowView.m
...emonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBShowView.m
+43
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBTableViewController.h
.../Core/Plugin/Sanbox/VC/DB/DoraemonDBTableViewController.h
+0
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBTableViewController.m
.../Core/Plugin/Sanbox/VC/DB/DoraemonDBTableViewController.m
+129
-0
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DoraemonDBTableViewController.m
...Src/Core/Plugin/Sanbox/VC/DoraemonDBTableViewController.m
+0
-24
未找到文件。
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/Util/DoraemonDBManager.h
浏览文件 @
bdad3901
...
...
@@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
copy
)
NSString
*
tableName
;
-
(
NSArray
*
)
tablesAtDB
;
-
(
NSArray
*
)
dataAtTable
;
@end
...
...
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/Util/DoraemonDBManager.m
浏览文件 @
bdad3901
...
...
@@ -10,7 +10,7 @@
@interface
DoraemonDBManager
()
@property
(
nonatomic
,
strong
)
NSMutableArray
*
dataArray
;
@end
...
...
@@ -56,6 +56,61 @@
return
tableNameArray
;
}
//获取每一张表中的所有数据
-
(
NSArray
*
)
dataAtTable
{
sqlite3
*
db
=
[
self
openDB
];
if
(
db
==
nil
)
{
return
nil
;
}
//查询sqlite_master表
NSString
*
sql
=
[
NSString
stringWithFormat
:
@"select * from %@"
,
self
.
tableName
];
//执行sql
char
*
errmsg
=
nil
;
sqlite3_exec
(
db
,
[
sql
UTF8String
],
selectCallback
,
nil
,
&
errmsg
);
//处理数据
NSMutableArray
*
arrayM
=
[
NSMutableArray
arrayWithArray
:
self
.
dataArray
];
[
self
.
dataArray
removeAllObjects
];
return
arrayM
;
}
//查询回调
int
selectCallback
(
void
*
firstValue
,
int
columnCount
,
char
**
columnValues
,
char
**
columnNames
)
{
NSMutableDictionary
*
dict
=
[
NSMutableDictionary
dictionary
];
for
(
int
i
=
0
;
i
<
columnCount
;
i
++
)
{
//获取当前的列表(字段名)
char
*
columnName
=
columnNames
[
i
];
NSString
*
nameStr
=
nil
;
if
(
columnName
==
NULL
)
{
nameStr
=
nil
;
}
else
{
nameStr
=
[
NSString
stringWithUTF8String
:
columnName
];
}
//获取当前字段的值
char
*
columnValue
=
columnValues
[
i
];
NSString
*
valueStr
=
nil
;
if
(
columnValue
==
NULL
)
{
valueStr
=
nil
;
}
else
{
valueStr
=
[
NSString
stringWithUTF8String
:
columnValue
];
}
[
dict
setValue
:
valueStr
forKey
:
nameStr
];
}
[[[
DoraemonDBManager
shareManager
]
dataArray
]
addObject
:
dict
];
return
0
;
}
#pragma mark - 懒加载
-
(
NSMutableArray
*
)
dataArray
{
if
(
_dataArray
==
nil
)
{
_dataArray
=
[
NSMutableArray
array
];
}
return
_dataArray
;
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBCell.h
0 → 100644
浏览文件 @
bdad3901
//
// DoraemonDBCell.h
// AFNetworking
//
// Created by yixiang on 2019/4/1.
//
#import <UIKit/UIKit.h>
#import "DoraemonDBRowView.h"
NS_ASSUME_NONNULL_BEGIN
@interface
DoraemonDBCell
:
UITableViewCell
@property
(
nonatomic
,
strong
)
DoraemonDBRowView
*
rowView
;
-
(
void
)
renderCellWithArray
:(
NSArray
*
)
array
;
@end
NS_ASSUME_NONNULL_END
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBCell.m
0 → 100644
浏览文件 @
bdad3901
//
// DoraemonDBCell.m
// AFNetworking
//
// Created by yixiang on 2019/4/1.
//
#import "DoraemonDBCell.h"
#import "DoraemonDBRowView.h"
@interface
DoraemonDBCell
()
@end
@implementation
DoraemonDBCell
-
(
instancetype
)
initWithStyle
:(
UITableViewCellStyle
)
style
reuseIdentifier
:(
NSString
*
)
reuseIdentifier
{
self
=
[
super
initWithStyle
:
style
reuseIdentifier
:
reuseIdentifier
];
if
(
self
)
{
_rowView
=
[[
DoraemonDBRowView
alloc
]
init
];
[
self
.
contentView
addSubview
:
_rowView
];
}
return
self
;
}
-
(
void
)
layoutSubviews
{
[
super
layoutSubviews
];
_rowView
.
frame
=
self
.
contentView
.
bounds
;
}
-
(
void
)
renderCellWithArray
:(
NSArray
*
)
array
{
_rowView
.
dataArray
=
array
;
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBRowView.h
0 → 100644
浏览文件 @
bdad3901
//
// DoraemonDBRowView.h
// AFNetworking
//
// Created by yixiang on 2019/4/1.
//
#import <UIKit/UIKit.h>
@class
DoraemonDBRowView
;
typedef
NS_ENUM
(
NSInteger
,
DoraemonDBRowViewType
)
{
DoraemonDBRowViewTypeForTitle
=
0
,
DoraemonDBRowViewTypeForOne
=
1
,
DoraemonDBRowViewTypeForTwo
=
2
};
@protocol
DoraemonDBRowViewTypeDelegate
<
NSObject
>
-
(
void
)
rowView
:(
DoraemonDBRowView
*
)
rowView
didLabelTaped
:(
UILabel
*
)
label
;
@end
@interface
DoraemonDBRowView
:
UIView
@property
(
nonatomic
,
copy
)
NSArray
*
dataArray
;
@property
(
nonatomic
,
assign
)
DoraemonDBRowViewType
type
;
@property
(
nonatomic
,
weak
)
id
<
DoraemonDBRowViewTypeDelegate
>
delegate
;
@end
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBRowView.m
0 → 100644
浏览文件 @
bdad3901
//
// DoraemonDBRowView.m
// AFNetworking
//
// Created by yixiang on 2019/4/1.
//
#import "DoraemonDBRowView.h"
#import "DoraemonDefine.h"
@implementation
DoraemonDBRowView
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
{
if
(
self
=
[
super
initWithFrame
:
frame
])
{
}
return
self
;
}
-
(
void
)
setDataArray
:(
NSArray
*
)
dataArray
{
_dataArray
=
dataArray
;
for
(
UIView
*
sub
in
self
.
subviews
)
{
[
sub
removeFromSuperview
];
}
for
(
int
i
=
0
;
i
<
self
.
dataArray
.
count
;
i
++
)
{
NSString
*
content
=
self
.
dataArray
[
i
];
UILabel
*
label
=
[[
UILabel
alloc
]
init
];
UIColor
*
color
=
[
UIColor
doraemon_colorWithString
:
@"#dcdcdc"
];
if
(
self
.
type
==
DoraemonDBRowViewTypeForOne
)
{
color
=
[
UIColor
doraemon_colorWithString
:
@"#e6e6e6"
];
}
if
(
self
.
type
==
DoraemonDBRowViewTypeForTwo
)
{
color
=
[
UIColor
doraemon_colorWithString
:
@"#ebebeb"
];
}
label
.
backgroundColor
=
color
;
label
.
text
=
content
;
label
.
textAlignment
=
NSTextAlignmentCenter
;
label
.
tag
=
i
;
label
.
userInteractionEnabled
=
YES
;
[
label
addGestureRecognizer
:[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
tapLabel
:)]];
[
self
addSubview
:
label
];
}
}
-
(
void
)
layoutSubviews
{
[
super
layoutSubviews
];
for
(
UIView
*
subView
in
self
.
subviews
)
{
if
([
subView
isKindOfClass
:
UILabel
.
class
])
{
CGFloat
width
=
(
self
.
bounds
.
size
.
width
-
(
self
.
dataArray
.
count
-
1
))
/
self
.
dataArray
.
count
;
subView
.
frame
=
CGRectMake
(
subView
.
tag
*
(
width
+
1
),
0
,
width
,
self
.
bounds
.
size
.
height
);
}
}
}
-
(
void
)
tapLabel
:(
UITapGestureRecognizer
*
)
tap
{
UILabel
*
label
=
(
UILabel
*
)
tap
.
view
;
if
([
self
.
delegate
respondsToSelector
:
@selector
(
rowView
:
didLabelTaped
:
)])
{
[
self
.
delegate
rowView
:
self
didLabelTaped
:
label
];
}
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBShowView.h
0 → 100644
浏览文件 @
bdad3901
//
// DoraemonDBShowView.h
// AFNetworking
//
// Created by yixiang on 2019/4/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface
DoraemonDBShowView
:
UIView
-
(
void
)
showText
:(
NSString
*
)
text
;
@end
NS_ASSUME_NONNULL_END
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBShowView.m
0 → 100644
浏览文件 @
bdad3901
//
// DoraemonDBShowView.m
// AFNetworking
//
// Created by yixiang on 2019/4/1.
//
#import "DoraemonDBShowView.h"
#import "DoraemonDefine.h"
@interface
DoraemonDBShowView
()
@property
(
nonatomic
,
strong
)
UILabel
*
displayLabel
;
@end
@implementation
DoraemonDBShowView
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
{
self
=
[
super
initWithFrame
:
frame
];
if
(
self
)
{
_displayLabel
=
[[
UILabel
alloc
]
init
];
_displayLabel
.
numberOfLines
=
0
;
_displayLabel
.
textAlignment
=
NSTextAlignmentCenter
;
_displayLabel
.
backgroundColor
=
[
UIColor
doraemon_colorWithString
:
@"#AAAAAA"
];
[
self
addSubview
:
_displayLabel
];
}
return
self
;
}
-
(
void
)
showText
:(
NSString
*
)
text
{
_displayLabel
.
frame
=
CGRectMake
(
self
.
doraemon_width
/
2
-
150
/
2
,
self
.
doraemon_height
/
2
-
100
/
2
,
150
,
100
);
__weak
typeof
(
self
)
weakSelf
=
self
;
[
UIView
animateWithDuration
:
0
.
25
animations
:
^
{
__strong
__typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
displayLabel
.
frame
=
CGRectMake
(
self
.
doraemon_width
/
2
-
300
/
2
,
self
.
doraemon_height
/
2
-
200
/
2
,
300
,
200
);
}
completion
:^
(
BOOL
finished
)
{
__strong
__typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
strongSelf
.
displayLabel
.
text
=
text
;
}];
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DoraemonDBTableViewController.h
→
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/D
B/D
oraemonDBTableViewController.h
浏览文件 @
bdad3901
文件已移动
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DB/DoraemonDBTableViewController.m
0 → 100644
浏览文件 @
bdad3901
//
// DoraemonDBTableViewController.m
// AFNetworking
//
// Created by yixiang on 2019/3/31.
//
#import "DoraemonDBTableViewController.h"
#import "DoraemonDBManager.h"
#import "DoraemonDBRowView.h"
#import "DoraemonDBCell.h"
#import "DoraemonDBShowView.h"
@interface
DoraemonDBTableViewController
()
<
UITableViewDelegate
,
UITableViewDataSource
,
DoraemonDBRowViewTypeDelegate
>
@property
(
nonatomic
,
strong
)
UIScrollView
*
scrollView
;
@property
(
nonatomic
,
strong
)
UITableView
*
tableView
;
@property
(
nonatomic
,
copy
)
NSArray
*
dataAtTable
;
@property
(
nonatomic
,
strong
)
DoraemonDBShowView
*
showView
;
@end
@implementation
DoraemonDBTableViewController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
title
=
[
DoraemonDBManager
shareManager
].
tableName
;
NSArray
*
dataAtTable
=
[[
DoraemonDBManager
shareManager
]
dataAtTable
];
self
.
dataAtTable
=
dataAtTable
;
UIScrollView
*
scrollView
=
[[
UIScrollView
alloc
]
initWithFrame
:
self
.
view
.
bounds
];
scrollView
.
backgroundColor
=
[
UIColor
whiteColor
];
scrollView
.
bounces
=
NO
;
[
self
.
view
addSubview
:
scrollView
];
self
.
scrollView
=
scrollView
;
UITableView
*
tableView
=
[[
UITableView
alloc
]
init
];
tableView
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
tableView
.
backgroundColor
=
[
UIColor
whiteColor
];
tableView
.
delegate
=
self
;
tableView
.
dataSource
=
self
;
[
self
.
scrollView
addSubview
:
tableView
];
self
.
tableView
=
tableView
;
}
-
(
void
)
viewWillLayoutSubviews
{
[
super
viewWillLayoutSubviews
];
if
(
self
.
dataAtTable
.
count
)
{
NSDictionary
*
dict
=
self
.
dataAtTable
.
firstObject
;
NSUInteger
num
=
[
dict
allKeys
].
count
;
self
.
tableView
.
frame
=
CGRectMake
(
0
,
0
,
num
*
200
,
self
.
scrollView
.
frame
.
size
.
height
);
self
.
scrollView
.
contentSize
=
CGSizeMake
(
self
.
tableView
.
frame
.
size
.
width
,
self
.
tableView
.
bounds
.
size
.
height
);
}
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
-
(
NSInteger
)
numberOfSectionsInTableView
:(
UITableView
*
)
tableView
{
return
self
.
dataAtTable
.
count
==
0
?
0
:
1
;
}
-
(
UIView
*
)
tableView
:(
UITableView
*
)
tableView
viewForHeaderInSection
:(
NSInteger
)
section
{
DoraemonDBRowView
*
headerView
=
nil
;
if
(
headerView
==
nil
)
{
headerView
=
[[
DoraemonDBRowView
alloc
]
init
];
}
NSDictionary
*
dict
=
self
.
dataAtTable
.
firstObject
;
headerView
.
dataArray
=
[
dict
allKeys
];
return
headerView
;
}
-
(
CGFloat
)
tableView
:(
UITableView
*
)
tableView
heightForHeaderInSection
:(
NSInteger
)
section
{
return
44
;
}
-
(
NSInteger
)
tableView
:(
UITableView
*
)
tableView
numberOfRowsInSection
:(
NSInteger
)
section
{
return
self
.
dataAtTable
.
count
;
}
-
(
UITableViewCell
*
)
tableView
:(
UITableView
*
)
tableView
cellForRowAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
static
NSString
*
identifer
=
@"db_data"
;
DoraemonDBCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:
identifer
];
if
(
cell
==
nil
)
{
cell
=
[[
DoraemonDBCell
alloc
]
initWithStyle
:
UITableViewCellStyleValue1
reuseIdentifier
:
identifer
];
cell
.
selectionStyle
=
UITableViewCellSelectionStyleNone
;
cell
.
rowView
.
delegate
=
self
;
}
cell
.
rowView
.
type
=
(
indexPath
.
row
%
2
==
0
)
?
DoraemonDBRowViewTypeForOne
:
DoraemonDBRowViewTypeForTwo
;
NSDictionary
*
dict
=
self
.
dataAtTable
[
indexPath
.
row
];
[
cell
renderCellWithArray
:[
dict
allValues
]];
return
cell
;
}
#pragma mark -- DoraemonDBRowViewTypeDelegate
-
(
void
)
rowView
:(
DoraemonDBRowView
*
)
rowView
didLabelTaped
:(
UILabel
*
)
label
{
NSString
*
content
=
label
.
text
;
NSLog
(
@"%@"
,
content
);
[
self
showText
:
content
];
}
#pragma mark -- 显示弹出文案
-
(
void
)
showText
:(
NSString
*
)
content
{
if
(
self
.
showView
)
{
[
self
.
showView
removeFromSuperview
];
}
self
.
showView
=
[[
DoraemonDBShowView
alloc
]
initWithFrame
:
self
.
view
.
bounds
];
[
self
.
view
addSubview
:
self
.
showView
];
UITapGestureRecognizer
*
tap
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
dismissView
)];
self
.
showView
.
userInteractionEnabled
=
YES
;
[
self
.
showView
addGestureRecognizer
:
tap
];
[
self
.
showView
showText
:
content
];
}
-
(
void
)
dismissView
{
if
(
self
.
showView
)
{
[
self
.
showView
removeFromSuperview
];
}
}
@end
iOS/DoraemonKit/Src/Core/Plugin/Sanbox/VC/DoraemonDBTableViewController.m
已删除
100644 → 0
浏览文件 @
ac4dbfc9
//
// DoraemonDBTableViewController.m
// AFNetworking
//
// Created by yixiang on 2019/3/31.
//
#import "DoraemonDBTableViewController.h"
#import "DoraemonDBManager.h"
@interface
DoraemonDBTableViewController
()
@end
@implementation
DoraemonDBTableViewController
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
title
=
[
DoraemonDBManager
shareManager
].
tableName
;
}
@end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录