lycan_pay_sdk 1.0.1 lycan_pay_sdk: ^1.0.1 copied to clipboard
A new flutter Lycan Pay SDK project.
example/lib/main.dart
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:lycan_pay_sdk/lycan_payment.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: ProductPageScreen(),
),
);
}
}
class ProductPageScreen extends StatefulWidget {
const ProductPageScreen({Key? key}) : super(key: key);
@override
State<ProductPageScreen> createState() => _ProductPageScreenState();
}
class _ProductPageScreenState extends State<ProductPageScreen> {
List product = [
{
"amt": "10.00",
"img":
"https://cdn.pixabay.com/photo/2020/05/26/09/32/product-5222398_1280.jpg",
"name": "Sunglasses E345",
"des":
"Online shopping Accessories from a great selection of Sunglasses, Spectacle Frames, Glasses Cases & more at everyday",
},
{
"amt": "0.5",
"img":
"https://bluewatermarketing.com/wp-content/uploads/2022/01/S3_07564-Edit.jpg",
"name": "BEARD OIL",
"des":
"Beard oil is a cosmetic product for men that is used to nourish both the skin under the beard and the beard itself in order to keep it soft, shiny, and smooth. Beard oil mimics the natural oils produced by skin, such as sebum, and is composed mainly of carrier oils and essential oils.",
},
{
"amt": "25.00",
"img":
"https://thumbs.dreamstime.com/b/mini-smart-speaker-white-background-115617109.jpg",
"name": "Alexa 2312",
"des":
"Alexa is the intelligent cloud-based voice AI that you can talk to on Alexa. Speak to Alexa through Alexa to play music, hear the news, check weather, control smart home devices, and more.",
},
{
"amt": "45.25",
"img":
"https://d2xamzlzrdbdbn.cloudfront.net/products/9af0c62e-99d5-4409-9601-3638b743f1fe22060750.jpg",
"name": "BOAT 131",
"des":
"Airdopes 131 wireless earbuds offer battery backup of up to 3 hours on a single charge. They also give a total playback time of 12 hours along with the charging case.",
},
{
"amt": "75.75",
"img":
"https://positiveroutines.com/wp-content/uploads/2018/10/black-headphones-against-yellow-background.jpg",
"name": "HEAD PHONE",
"des":
"Headphones are a pair of small loudspeaker drivers worn on or around the head over a user's ears. They are electroacoustic transducers, which convert an electrical signal to a corresponding sound.",
},
{
"amt": "15.90",
"img":
"https://www.photoalter.com/images/product-photo-retouching-services-before.png",
"name": "Jaguar-1",
"des":
"Product Specification \nGender: Men \nType: Running Shoes \nSize: 6*9/7*10 \nColor: Red/Black,Navy/Sky,Dark Grey/Red \nArticle No: Jaguar-1.",
},
{
"amt": "9.99",
"img":
"https://www.mockupworld.co/wp-content/uploads/dynamic/2021/09/free-iphone-13-mockup-red-psd-536x0-c-default.jpg",
"name": "IPHONE Case",
"des":
"A hard phone case is typically a hard shell-like case that is molded precisely for a specific phone version that snaps onto the phone.",
},
];
@override
Widget build(BuildContext context) {
final orientation = MediaQuery.of(context).orientation;
return Scaffold(
body: SafeArea(
child: GridView.builder(
itemCount: product.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
BuyNowPage(data: product[index], index: index)),
);
},
child: Card(
child: GridTile(
footer: Container(
height: 40,
color: Colors.grey.withOpacity(0.7),
child: Center(
child: Text(
"Price: ${product[index]["amt"]}",
style: const TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.w500),
)),
),
child: Hero(
tag: "img$index",
child: Image.network(
product[index]['img'],
fit: BoxFit.fill,
),
), //just for testing, will fill with image later
),
),
);
},
),
));
}
}
class BuyNowPage extends StatefulWidget {
final Map data;
final int index;
const BuyNowPage({Key? key, required this.data, required this.index})
: super(key: key);
@override
State<BuyNowPage> createState() => _BuyNowPageState();
}
class _BuyNowPageState extends State<BuyNowPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
automaticallyImplyLeading: true,
leading: IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(
Icons.arrow_back_ios,
color: Colors.black,
),
),
),
body: SafeArea(
child: Container(
padding: const EdgeInsets.all(20),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
tag: "img${widget.index}",
child: SizedBox(
height: 250,
child: Image.network(widget.data["img"], fit: BoxFit.fill),
),
),
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text(
"${widget.data["name"]}",
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 25),
),
),
const Padding(
padding: EdgeInsets.only(top: 5),
child: Text(
"Rating : ⭐⭐⭐⭐⭐",
style: TextStyle(fontWeight: FontWeight.w700),
),
),
Padding(
padding: const EdgeInsets.only(top: 10),
child: Text(
"${widget.data["des"]}",
textAlign: TextAlign.justify,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(top: 15, bottom: 20),
child: Text(
"\$${widget.data["amt"]}",
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 30),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: List.generate(
35,
(index) => Container(
height: 1,
width: 3,
color: const Color.fromARGB(255, 37, 53, 89))),
),
const Padding(
padding: EdgeInsets.only(top: 10, bottom: 12),
child: Text(
"Payments",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: List.generate(
35,
(index) => Container(
height: 1,
width: 3,
color: const Color.fromARGB(255, 37, 53, 89))),
),
const SizedBox(height: 20),
LycanPaySDK(
amount: widget.data["amt"],
name: "LycanPay",
email: "example@gmail.com",
merchantID: "0800E2C4C7024E",
idTestMode: 0,
invoiceNo: "INV00${Random().nextInt(9)}",
backCurrentPageNav: BuyNowPage(
data: widget.data,
index: widget.index,
),
)
],
),
),
)),
);
}
}