123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import 'package:card_swiper/card_swiper.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_wallet/generated/l10n.dart';
- import 'package:flutter_wallet/tools/YSTools.dart';
- import '../../tools/YSColors.dart';
- import '../../tools/YSNetWork.dart';
- import '../YSFind.dart';
- class YSBannerView extends StatefulWidget {
- const YSBannerView({Key? key}) : super(key: key);
- @override
- YSBannerViewState createState() => YSBannerViewState();
- }
- class YSBannerViewState extends State<YSBannerView> {
- List _banners = [];
- @override
- void initState() {
- networkDelay((){
- _getBanners();
- });
- super.initState();
- }
- _getBanners() async{
- YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'banners', parameter: {'lang':S.current.LAUGUAGE=='English'?'en':''}, successSetter: (dict){
- _banners = dict['data']['list']??[];
- setState(() {});
- });
- }
- @override
- Widget build(BuildContext context) {
- return _banners.isNotEmpty?Swiper(
- itemCount: _banners.length,
- itemBuilder: (context,index){
- Map item = _banners[index];
- return Padding(
- padding: EdgeInsets.only(left: hsp(5),right: hsp(5)),
- child: GestureDetector(
- onTap: (){
- intoPage(context,item['jump_url']);
- },
- child: ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(10)),
- child: Container(
- width: ysWidth(context),
- color: YSColors.containColor(context),
- child: YSImage.network(item['image_url'],),
- ),
- ),
- ),
- );
- },
- pagination: SwiperPagination(
- builder: DotSwiperPaginationBuilder(
- color: Colors.white.withOpacity(0.6),
- activeColor: Colors.white,
- activeSize: hsp(10),
- size: hsp(8),
- )
- ),
- autoplay: true,
- ):Container();
- }
- }
|