mirror of
https://github.com/OpenFlutter/fluwx.git
synced 2025-08-26 16:22:04 +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/fluwx.dart';
|
||||||
import 'package:fluwx_example/send_auth.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 'package:fluwx_example/share_video_page.dart';
|
||||||
import 'share_music.dart';
|
import 'share_music.dart';
|
||||||
import 'share_web_page.dart';
|
import 'share_web_page.dart';
|
||||||
@ -31,11 +32,12 @@ class _MyAppState extends State<MyApp> {
|
|||||||
return new MaterialApp(
|
return new MaterialApp(
|
||||||
routes: <String, WidgetBuilder>{
|
routes: <String, WidgetBuilder>{
|
||||||
"shareText": (context) => ShareTextPage(),
|
"shareText": (context) => ShareTextPage(),
|
||||||
"shareImage":(context) => ShareImagePage(),
|
"shareImage": (context) => ShareImagePage(),
|
||||||
"shareWebPage":(context) => ShareWebPagePage(),
|
"shareWebPage": (context) => ShareWebPagePage(),
|
||||||
"shareMusic":(context) => ShareMusicPage(),
|
"shareMusic": (context) => ShareMusicPage(),
|
||||||
"shareVideo":(context) => ShareVideoPage(),
|
"shareVideo": (context) => ShareVideoPage(),
|
||||||
"sendAuth":(context) => SendAuthPage(),
|
"sendAuth": (context) => SendAuthPage(),
|
||||||
|
"shareMiniProgram":(context) => ShareMiniProgramPage()
|
||||||
},
|
},
|
||||||
home: new Scaffold(
|
home: new Scaffold(
|
||||||
appBar: new AppBar(
|
appBar: new AppBar(
|
||||||
@ -54,43 +56,59 @@ class ShareSelectorPage extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: new OutlineButton(onPressed: () {
|
child: new OutlineButton(
|
||||||
Navigator.of(context).pushNamed("shareText");
|
onPressed: () {
|
||||||
}, child: const Text("share text")),
|
Navigator.of(context).pushNamed("shareText");
|
||||||
|
},
|
||||||
|
child: const Text("share text")),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: new OutlineButton(onPressed: () {
|
child: new OutlineButton(
|
||||||
Navigator.of(context).pushNamed("shareImage");
|
onPressed: () {
|
||||||
}, child: const Text("share image")),
|
Navigator.of(context).pushNamed("shareImage");
|
||||||
|
},
|
||||||
|
child: const Text("share image")),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: new OutlineButton(onPressed: () {
|
child: new OutlineButton(
|
||||||
Navigator.of(context).pushNamed("shareWebPage");
|
onPressed: () {
|
||||||
|
Navigator.of(context).pushNamed("shareWebPage");
|
||||||
}, child: const Text("share webpage")),
|
},
|
||||||
|
child: const Text("share webpage")),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: new OutlineButton(onPressed: () {
|
child: new OutlineButton(
|
||||||
Navigator.of(context).pushNamed("shareMusic");
|
onPressed: () {
|
||||||
|
Navigator.of(context).pushNamed("shareMusic");
|
||||||
}, child: const Text("share music")),
|
},
|
||||||
|
child: const Text("share music")),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: new OutlineButton(onPressed: () {
|
child: new OutlineButton(
|
||||||
Navigator.of(context).pushNamed("shareVideo");
|
onPressed: () {
|
||||||
|
Navigator.of(context).pushNamed("shareVideo");
|
||||||
}, child: const Text("share video")),
|
},
|
||||||
|
child: const Text("share video")),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: new OutlineButton(onPressed: () {
|
child: new OutlineButton(
|
||||||
Navigator.of(context).pushNamed("sendAuth");
|
onPressed: () {
|
||||||
|
Navigator.of(context).pushNamed("shareMiniProgram");
|
||||||
}, child: const Text("send auth")),
|
},
|
||||||
|
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