mirror of
https://github.com/OpenFlutter/fluwx.git
synced 2025-08-26 08:13:38 +08:00
demo:share miniprogram
This commit is contained in:
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:fluwx_example/send_auth.dart';
|
||||
import 'package:fluwx_example/share_mini_program.dart';
|
||||
import 'package:fluwx_example/share_video_page.dart';
|
||||
import 'share_music.dart';
|
||||
import 'share_web_page.dart';
|
||||
@ -31,11 +32,12 @@ class _MyAppState extends State<MyApp> {
|
||||
return new MaterialApp(
|
||||
routes: <String, WidgetBuilder>{
|
||||
"shareText": (context) => ShareTextPage(),
|
||||
"shareImage":(context) => ShareImagePage(),
|
||||
"shareWebPage":(context) => ShareWebPagePage(),
|
||||
"shareMusic":(context) => ShareMusicPage(),
|
||||
"shareVideo":(context) => ShareVideoPage(),
|
||||
"sendAuth":(context) => SendAuthPage(),
|
||||
"shareImage": (context) => ShareImagePage(),
|
||||
"shareWebPage": (context) => ShareWebPagePage(),
|
||||
"shareMusic": (context) => ShareMusicPage(),
|
||||
"shareVideo": (context) => ShareVideoPage(),
|
||||
"sendAuth": (context) => SendAuthPage(),
|
||||
"shareMiniProgram":(context) => ShareMiniProgramPage()
|
||||
},
|
||||
home: new Scaffold(
|
||||
appBar: new AppBar(
|
||||
@ -54,43 +56,59 @@ class ShareSelectorPage extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new OutlineButton(onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareText");
|
||||
}, child: const Text("share text")),
|
||||
child: new OutlineButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareText");
|
||||
},
|
||||
child: const Text("share text")),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new OutlineButton(onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareImage");
|
||||
}, child: const Text("share image")),
|
||||
child: new OutlineButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareImage");
|
||||
},
|
||||
child: const Text("share image")),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new OutlineButton(onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareWebPage");
|
||||
|
||||
}, child: const Text("share webpage")),
|
||||
child: new OutlineButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareWebPage");
|
||||
},
|
||||
child: const Text("share webpage")),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new OutlineButton(onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareMusic");
|
||||
|
||||
}, child: const Text("share music")),
|
||||
child: new OutlineButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareMusic");
|
||||
},
|
||||
child: const Text("share music")),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new OutlineButton(onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareVideo");
|
||||
|
||||
}, child: const Text("share video")),
|
||||
child: new OutlineButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareVideo");
|
||||
},
|
||||
child: const Text("share video")),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new OutlineButton(onPressed: () {
|
||||
Navigator.of(context).pushNamed("sendAuth");
|
||||
|
||||
}, child: const Text("send auth")),
|
||||
child: new OutlineButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("shareMiniProgram");
|
||||
},
|
||||
child: const Text("share mini program")),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new OutlineButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed("sendAuth");
|
||||
},
|
||||
child: const Text("send auth")),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
115
example/lib/share_mini_program.dart
Normal file
115
example/lib/share_mini_program.dart
Normal file
@ -0,0 +1,115 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
|
||||
class ShareMiniProgramPage extends StatefulWidget {
|
||||
@override
|
||||
_ShareMiniProgramPageState createState() => _ShareMiniProgramPageState();
|
||||
}
|
||||
|
||||
class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
|
||||
|
||||
Fluwx fluwx;
|
||||
WeChatScene scene = WeChatScene.SESSION;
|
||||
String _webPageUr = "http://www.qq.com";
|
||||
String _thumbnail =
|
||||
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534614311230&di=b17a892b366b5d002f52abcce7c4eea0&imgtype=0&src=http%3A%2F%2Fimg.mp.sohu.com%2Fupload%2F20170516%2F51296b2673704ae2992d0a28c244274c_th.png";
|
||||
String _title = "Fluwx";
|
||||
String _userName = "gh_d43f693ca31f";
|
||||
String _path = "/pages/media";
|
||||
String _description = "Fluwx";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
fluwx = new Fluwx();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
new Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("ShareMiniProgram"),
|
||||
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: "http://www.qq.com"),
|
||||
onChanged: (str){
|
||||
_webPageUr = str;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: "web page url"
|
||||
),
|
||||
),
|
||||
new TextField(
|
||||
controller: TextEditingController(text: "gh_d43f693ca31f"),
|
||||
onChanged: (str){
|
||||
_userName = str;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: "user name"
|
||||
),
|
||||
),
|
||||
new TextField(
|
||||
controller: TextEditingController(text: "/pages/media"),
|
||||
onChanged: (str){
|
||||
_path = str;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: "user name"
|
||||
),
|
||||
),
|
||||
new TextField(
|
||||
controller: TextEditingController(text: "Fluwx"),
|
||||
onChanged: (str){
|
||||
_title = str;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: "title"
|
||||
),
|
||||
),
|
||||
new TextField(
|
||||
controller: TextEditingController(text: "Fluwx"),
|
||||
onChanged: (str){
|
||||
_description = str;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: "description"
|
||||
),
|
||||
),
|
||||
new TextField(
|
||||
controller: TextEditingController(text: "assets://images/logo.png"),
|
||||
onChanged: (str){
|
||||
_thumbnail = str;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: "thumbnail"
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _share() {
|
||||
var model =new WeChatShareMiniProgramModel(
|
||||
webPageUrl: _webPageUr,
|
||||
miniProgramType: WeChatShareMiniProgramModel.MINI_PROGRAM_TYPE_RELEASE,
|
||||
userName: _userName,
|
||||
title: _title,
|
||||
description: _description,
|
||||
thumbnail: _thumbnail
|
||||
);
|
||||
fluwx.share(model);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user