提交 6aa5dc9c authored 作者: JarvanMo's avatar JarvanMo

share web page demo

上级 bce1a71c
......@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'dart:async';
import 'package:fluwx/fluwx.dart';
import 'package:fluwx_example/share_web_page.dart';
import 'share_image_page.dart';
import 'share_text_image.dart';
......@@ -27,7 +28,8 @@ class _MyAppState extends State<MyApp> {
return new MaterialApp(
routes: <String, WidgetBuilder>{
"shareText": (context) => ShareTextPage(),
"shareImage":(context) => ShareImagePage()
"shareImage":(context) => ShareImagePage(),
"shareWebPage":(context) => ShareWebPagePage(),
},
home: new Scaffold(
appBar: new AppBar(
......@@ -74,7 +76,10 @@ class ShareSelectorPage extends StatelessWidget {
new OutlineButton(onPressed: () {
Navigator.of(context).pushNamed("shareImage");
}, child: const Text("share image")),
new OutlineButton(onPressed: () {}, child: const Text("share webpage")),
new OutlineButton(onPressed: () {
Navigator.of(context).pushNamed("shareWebPage");
}, child: const Text("share webpage")),
],
);
}
......
import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart';
class ShareWebPagePage extends StatefulWidget {
@override
ShareWebPagePageState createState() {
return new ShareWebPagePageState();
}
}
class ShareWebPagePageState extends State<ShareWebPagePage> {
Fluwx fluwx;
String _url = "share text from fluwx";
String _title = "Fluwx";
String _thumnail ="assets://images/logo.png";
WeChatScene scene = WeChatScene.SESSION;
@override
void initState() {
super.initState();
fluwx = new Fluwx();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: const Text("ShareWebPage"),
actions: <Widget>[
IconButton(icon: Icon(Icons.share,color: Colors.white,), onPressed: _share)
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: new Column(
children: <Widget>[
new TextField(
controller: TextEditingController(text: "https://github.com/JarvanMo/fluwx"),
onChanged: (str){
_url = str;
},
decoration: InputDecoration(
labelText: "web page"
),
),
new TextField(
controller: TextEditingController(text: "Fluwx"),
onChanged: (str){
_title = str;
},
decoration: InputDecoration(
labelText: "thumbnail"
),
),
new TextField(
controller: TextEditingController(text: "assets://images/logo.png"),
onChanged: (str){
_thumnail = str;
},
decoration: InputDecoration(
labelText: "thumbnail"
),
),
new Row(
children: <Widget>[
const Text("分享至"),
Row(
children: <Widget>[
new Radio<WeChatScene>(
value: WeChatScene.SESSION,
groupValue: scene,
onChanged: handleRadioValueChanged
),
const Text("会话")
],
),
Row(
children: <Widget>[
new Radio<WeChatScene>(
value: WeChatScene.TIMELINE,
groupValue: scene,
onChanged: handleRadioValueChanged
),
const Text("朋友圈")
],
),
Row(
children: <Widget>[
new Radio<WeChatScene>(
value: WeChatScene.FAVORITE,
groupValue: scene,
onChanged: handleRadioValueChanged
),
const Text("收藏")
],
)
],
)
],
),
),
);
}
void _share() {
var model = WeChatShareWebPageModel(
webPage: _url,
title: _title,
thumbnail: _thumnail,
scene :scene,
transaction: "hh"
);
fluwx.share(model);
}
void handleRadioValueChanged(WeChatScene scene){
setState(() {
this.scene = scene;
});
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论