|
@@ -5,7 +5,6 @@ import 'CommonWebPage.dart';
|
|
import 'package:barcode_scan/barcode_scan.dart';
|
|
import 'package:barcode_scan/barcode_scan.dart';
|
|
|
|
|
|
class DiscoveryPage extends StatelessWidget {
|
|
class DiscoveryPage extends StatelessWidget {
|
|
-
|
|
|
|
static const String TAG_START = "startDivider";
|
|
static const String TAG_START = "startDivider";
|
|
static const String TAG_END = "endDivider";
|
|
static const String TAG_END = "endDivider";
|
|
static const String TAG_CENTER = "centerDivider";
|
|
static const String TAG_CENTER = "centerDivider";
|
|
@@ -23,10 +22,12 @@ class DiscoveryPage extends StatelessWidget {
|
|
"images/ic_discover_nearby.png",
|
|
"images/ic_discover_nearby.png",
|
|
"images/ic_discover_pos.png",
|
|
"images/ic_discover_pos.png",
|
|
];
|
|
];
|
|
- final titles = [
|
|
|
|
- "开源软件", "码云推荐", "代码片段", "扫一扫", "摇一摇", "码云封面人物", "线下活动"
|
|
|
|
- ];
|
|
|
|
- final rightArrowIcon = Image.asset('images/ic_arrow_right.png', width: ARROW_ICON_WIDTH, height: ARROW_ICON_WIDTH,);
|
|
|
|
|
|
+ final titles = ["开源软件", "码云推荐", "代码片段", "扫一扫", "摇一摇", "码云封面人物", "线下活动"];
|
|
|
|
+ final rightArrowIcon = Image.asset(
|
|
|
|
+ 'images/ic_arrow_right.png',
|
|
|
|
+ width: ARROW_ICON_WIDTH,
|
|
|
|
+ height: ARROW_ICON_WIDTH,
|
|
|
|
+ );
|
|
final titleTextStyle = TextStyle(fontSize: 16.0);
|
|
final titleTextStyle = TextStyle(fontSize: 16.0);
|
|
List listData = [];
|
|
List listData = [];
|
|
|
|
|
|
@@ -69,7 +70,8 @@ class DiscoveryPage extends StatelessWidget {
|
|
Widget getIconImage(path) {
|
|
Widget getIconImage(path) {
|
|
return Padding(
|
|
return Padding(
|
|
padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0),
|
|
padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0),
|
|
- child: Image.asset(path, width: IMAGE_ICON_WIDTH, height: IMAGE_ICON_WIDTH),
|
|
|
|
|
|
+ child:
|
|
|
|
+ Image.asset(path, width: IMAGE_ICON_WIDTH, height: IMAGE_ICON_WIDTH),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -78,15 +80,21 @@ class DiscoveryPage extends StatelessWidget {
|
|
if (item is String) {
|
|
if (item is String) {
|
|
switch (item) {
|
|
switch (item) {
|
|
case TAG_START:
|
|
case TAG_START:
|
|
- return Divider(height: 1.0,);
|
|
|
|
|
|
+ return Divider(
|
|
|
|
+ height: 1.0,
|
|
|
|
+ );
|
|
break;
|
|
break;
|
|
case TAG_END:
|
|
case TAG_END:
|
|
- return Divider(height: 1.0,);
|
|
|
|
|
|
+ return Divider(
|
|
|
|
+ height: 1.0,
|
|
|
|
+ );
|
|
break;
|
|
break;
|
|
case TAG_CENTER:
|
|
case TAG_CENTER:
|
|
return Padding(
|
|
return Padding(
|
|
padding: const EdgeInsets.fromLTRB(50.0, 0.0, 0.0, 0.0),
|
|
padding: const EdgeInsets.fromLTRB(50.0, 0.0, 0.0, 0.0),
|
|
- child: Divider(height: 1.0,),
|
|
|
|
|
|
+ child: Divider(
|
|
|
|
+ height: 1.0,
|
|
|
|
+ ),
|
|
);
|
|
);
|
|
break;
|
|
break;
|
|
case TAG_BLANK:
|
|
case TAG_BLANK:
|
|
@@ -96,14 +104,16 @@ class DiscoveryPage extends StatelessWidget {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
} else if (item is ListItem) {
|
|
} else if (item is ListItem) {
|
|
- var listItemContent = Padding(
|
|
|
|
|
|
+ var listItemContent = Padding(
|
|
padding: const EdgeInsets.fromLTRB(10.0, 15.0, 10.0, 15.0),
|
|
padding: const EdgeInsets.fromLTRB(10.0, 15.0, 10.0, 15.0),
|
|
child: Row(
|
|
child: Row(
|
|
children: [
|
|
children: [
|
|
getIconImage(item.icon),
|
|
getIconImage(item.icon),
|
|
Expanded(
|
|
Expanded(
|
|
- child: Text(item.title, style: titleTextStyle,)
|
|
|
|
- ),
|
|
|
|
|
|
+ child: Text(
|
|
|
|
+ item.title,
|
|
|
|
+ style: titleTextStyle,
|
|
|
|
+ )),
|
|
rightArrowIcon
|
|
rightArrowIcon
|
|
],
|
|
],
|
|
),
|
|
),
|
|
@@ -122,41 +132,33 @@ class DiscoveryPage extends StatelessWidget {
|
|
if (title == "扫一扫") {
|
|
if (title == "扫一扫") {
|
|
scan();
|
|
scan();
|
|
} else if (title == "线下活动") {
|
|
} else if (title == "线下活动") {
|
|
- Navigator.of(ctx).push(MaterialPageRoute(
|
|
|
|
- builder: (context) {
|
|
|
|
- return OfflineActivityPage();
|
|
|
|
- }
|
|
|
|
- ));
|
|
|
|
|
|
+ Navigator.of(ctx).push(MaterialPageRoute(builder: (context) {
|
|
|
|
+ return OfflineActivityPage();
|
|
|
|
+ }));
|
|
} else if (title == "码云推荐") {
|
|
} else if (title == "码云推荐") {
|
|
- Navigator.of(ctx).push(MaterialPageRoute(
|
|
|
|
- builder: (context) {
|
|
|
|
- return CommonWebPage(title: "码云推荐", url: "https://m.gitee.com/explore");
|
|
|
|
- }
|
|
|
|
- ));
|
|
|
|
|
|
+ Navigator.of(ctx).push(MaterialPageRoute(builder: (context) {
|
|
|
|
+ return CommonWebPage(title: "码云推荐", url: "https://m.gitee.com/explore");
|
|
|
|
+ }));
|
|
} else if (title == "代码片段") {
|
|
} else if (title == "代码片段") {
|
|
- Navigator.of(ctx).push(MaterialPageRoute(
|
|
|
|
- builder: (context) {
|
|
|
|
- return CommonWebPage(title: "代码片段", url: "https://m.gitee.com/gists");
|
|
|
|
- }
|
|
|
|
- ));
|
|
|
|
|
|
+ Navigator.of(ctx).push(MaterialPageRoute(builder: (context) {
|
|
|
|
+ return CommonWebPage(title: "代码片段", url: "https://m.gitee.com/gists");
|
|
|
|
+ }));
|
|
} else if (title == "开源软件") {
|
|
} else if (title == "开源软件") {
|
|
- Navigator.of(ctx).push(MaterialPageRoute(
|
|
|
|
- builder: (context) {
|
|
|
|
- return CommonWebPage(title: "开源软件", url: "https://m.gitee.com/explore");
|
|
|
|
- }
|
|
|
|
- ));
|
|
|
|
|
|
+ Navigator.of(ctx).push(MaterialPageRoute(builder: (context) {
|
|
|
|
+ return CommonWebPage(title: "开源软件", url: "https://m.gitee.com/explore");
|
|
|
|
+ }));
|
|
} else if (title == "码云封面人物") {
|
|
} else if (title == "码云封面人物") {
|
|
- Navigator.of(ctx).push(MaterialPageRoute(
|
|
|
|
- builder: (context) {
|
|
|
|
- return CommonWebPage(title: "码云封面人物", url: "https://m.gitee.com/gitee-stars/");
|
|
|
|
- }
|
|
|
|
- ));
|
|
|
|
|
|
+ Navigator.of(ctx).push(MaterialPageRoute(builder: (context) {
|
|
|
|
+ return CommonWebPage(
|
|
|
|
+ title: "码云封面人物", url: "https://m.gitee.com/gitee-stars/");
|
|
|
|
+ }));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Future scan() async {
|
|
Future scan() async {
|
|
try {
|
|
try {
|
|
- String barcode = await BarcodeScanner.scan();
|
|
|
|
|
|
+ ScanResult scanResult = await BarcodeScanner.scan();
|
|
|
|
+ String barcode = scanResult.rawContent.toString();
|
|
print(barcode);
|
|
print(barcode);
|
|
} on Exception catch (e) {
|
|
} on Exception catch (e) {
|
|
print(e);
|
|
print(e);
|
|
@@ -173,11 +175,10 @@ class DiscoveryPage extends StatelessWidget {
|
|
),
|
|
),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
class ListItem {
|
|
class ListItem {
|
|
String icon;
|
|
String icon;
|
|
String title;
|
|
String title;
|
|
ListItem({this.icon, this.title});
|
|
ListItem({this.icon, this.title});
|
|
-}
|
|
|
|
|
|
+}
|