forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGSYCommonOptionWidget.dart
More file actions
71 lines (61 loc) · 2.1 KB
/
GSYCommonOptionWidget.dart
File metadata and controls
71 lines (61 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
import 'package:share/share.dart';
/**
* Created by guoshuyu
* Date: 2018-07-26
*/
class GSYCommonOptionWidget extends StatelessWidget {
final List<GSYOptionModel> otherList;
final OptionControl control;
GSYCommonOptionWidget(this.control, {this.otherList});
_renderHeaderPopItem(List<GSYOptionModel> list) {
return new PopupMenuButton<GSYOptionModel>(
child: new Icon(GSYICons.MORE),
onSelected: (model) {
model.selected(model);
},
itemBuilder: (BuildContext context) {
return _renderHeaderPopItemChild(list);
},
);
}
_renderHeaderPopItemChild(List<GSYOptionModel> data) {
List<PopupMenuEntry<GSYOptionModel>> list = new List();
for (GSYOptionModel item in data) {
list.add(PopupMenuItem<GSYOptionModel>(
value: item,
child: new Text(item.name),
));
}
return list;
}
@override
Widget build(BuildContext context) {
List<GSYOptionModel> list = [
new GSYOptionModel(CommonUtils.getLocale(context).option_web, CommonUtils.getLocale(context).option_web, (model) {
CommonUtils.launchOutURL(control.url, context);
}),
new GSYOptionModel(CommonUtils.getLocale(context).option_copy, CommonUtils.getLocale(context).option_copy, (model) {
CommonUtils.copy(control.url ?? "", context);
}),
new GSYOptionModel(CommonUtils.getLocale(context).option_share, CommonUtils.getLocale(context).option_share, (model) {
Share.share(CommonUtils.getLocale(context).option_share_title + control.url ?? "");
}),
];
if (otherList != null && otherList.length > 0) {
list.addAll(otherList);
}
return _renderHeaderPopItem(list);
}
}
class OptionControl {
String url = GSYConstant.app_default_share_url;
}
class GSYOptionModel {
final String name;
final String value;
final PopupMenuItemSelected<GSYOptionModel> selected;
GSYOptionModel(this.name, this.value, this.selected);
}