You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
241 lines
9.4 KiB
241 lines
9.4 KiB
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:share_plus/share_plus.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:teso/util/SizeConfig.dart';
|
|
import 'package:teso/util/consts.dart';
|
|
|
|
class Referrals extends StatefulWidget {
|
|
const Referrals({Key key}) : super(key: key);
|
|
|
|
@override
|
|
_ReferralsState createState() => _ReferralsState();
|
|
}
|
|
|
|
class _ReferralsState extends State<Referrals> {
|
|
String refLink = "";
|
|
@override
|
|
void initState() {
|
|
SharedPreferences.getInstance().then((value) async {
|
|
setState(() {
|
|
refLink = value.getString("referral");
|
|
});
|
|
if (refLink == null) {
|
|
String uid = value.getString("id");
|
|
final ShortDynamicLink shortenedLink =
|
|
await DynamicLinkParameters.shortenUrl(
|
|
Uri.parse(dynamiclinkprefix +
|
|
'https://mobile.tesoapp.com/referral?referrer=' +
|
|
uid +
|
|
dynamiclinktrailing),
|
|
DynamicLinkParametersOptions(
|
|
shortDynamicLinkPathLength:
|
|
ShortDynamicLinkPathLength.unguessable),
|
|
);
|
|
setState(() {
|
|
refLink = shortenedLink.shortUrl.toString();
|
|
});
|
|
value.setString("referral", refLink);
|
|
}
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
SizeConfig().init(context);
|
|
return Scaffold(
|
|
body: refLink != null && refLink.isNotEmpty
|
|
? Stack(
|
|
children: [
|
|
Container(
|
|
height: MediaQuery.of(context).size.height * 0.5,
|
|
width: MediaQuery.of(context).size.width,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [tesoGold, tesoAsh, tesoBlue],
|
|
),
|
|
),
|
|
child: AppBar(
|
|
backgroundColor: Colors.transparent,
|
|
leading: Container(
|
|
margin: EdgeInsets.all(5),
|
|
height: 35,
|
|
width: 35,
|
|
decoration: BoxDecoration(
|
|
color: Color.fromRGBO(0, 0, 0, 0.4),
|
|
shape: BoxShape.circle),
|
|
child: IconButton(
|
|
icon: Icon(
|
|
Icons.arrow_back_ios,
|
|
color: Colors.white,
|
|
),
|
|
onPressed: () => Navigator.pop(context),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Align(
|
|
alignment: Alignment.center,
|
|
child: new Column(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: MediaQuery.of(context).size.width * 0.2,
|
|
),
|
|
margin: EdgeInsets.only(
|
|
top: SizeConfig.safeBlockHorizontal * 5),
|
|
child: Text(
|
|
"Invite Your Friend And Earn Silver Coin",
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w900,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Container(
|
|
width: SizeConfig.safeBlockHorizontal * 50,
|
|
height: SizeConfig.safeBlockHorizontal * 50,
|
|
child: Image.asset("assets/images/refer.png"),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
new Container(
|
|
alignment: Alignment.topCenter,
|
|
padding: new EdgeInsets.only(
|
|
top: MediaQuery.of(context).size.height * .44,
|
|
right: 10.0,
|
|
left: 10.0),
|
|
child: new Container(
|
|
// height: 80.0,
|
|
width: MediaQuery.of(context).size.width,
|
|
child: new Card(
|
|
//color: Colors.black,
|
|
elevation: 4.0,
|
|
child: new ListTile(
|
|
leading: Container(
|
|
child: Image.asset("assets/images/wallet.png"),
|
|
),
|
|
title: Text(
|
|
"Share your referral link and invite your friends via SMS, Email or Whatsapp and Earn up to 250 Silver Coins",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
child: Container(
|
|
margin: EdgeInsets.symmetric(
|
|
vertical: MediaQuery.of(context).size.width * 0.1),
|
|
height: MediaQuery.of(context).size.height * 0.28,
|
|
child: new Column(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal:
|
|
MediaQuery.of(context).size.width * 0.2,
|
|
),
|
|
child: Text(
|
|
"YOUR REFERRAL LINK",
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(
|
|
width: 2,
|
|
style: BorderStyle.solid,
|
|
),
|
|
),
|
|
padding: EdgeInsets.symmetric(
|
|
vertical: 10,
|
|
horizontal:
|
|
MediaQuery.of(context).size.width * 0.1,
|
|
),
|
|
width: MediaQuery.of(context).size.width * 0.8,
|
|
child: Text(
|
|
refLink,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: MediaQuery.of(context).size.width * 0.4,
|
|
margin: EdgeInsets.symmetric(vertical: 15),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(25.0),
|
|
),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
accentMain,
|
|
darkAccent,
|
|
],
|
|
),
|
|
),
|
|
child: TextButton.icon(
|
|
onPressed: () => Share.share(
|
|
'Join Teso App using my referral link and earn 5 silver coins ' +
|
|
refLink,
|
|
subject: 'Teso App!'),
|
|
icon: Icon(
|
|
Icons.share,
|
|
color: Colors.white,
|
|
),
|
|
label: Text(
|
|
"Share",
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
)
|
|
: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: Center(
|
|
child: CupertinoActivityIndicator(
|
|
animating: true,
|
|
radius: 15,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|