| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:wanna_battle/net/HttpManager.dart';
- Future getAppNotice(context) async {
- final res = await HttpManager.get('systemVariable/getOne', data: {
- 'variableName': 'appNotice',
- });
- if (res.success) {
- final String imageUrl = (res.data ?? {})['variableValue'] ?? '';
- if (imageUrl.isNotEmpty) {
- return showGeneralDialog(
- context: context,
- barrierDismissible: true,
- pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
- return AppNotice(
- pics: ((res.data ?? {})['variableValue'] ?? '').split(','),
- );
- },
- barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
- barrierColor: Colors.black87,
- transitionDuration: const Duration(milliseconds: 300),
- );
- }
- }
- }
- class AppNotice extends StatefulWidget {
- final List<String> pics;
- const AppNotice({Key key, this.pics}) : super(key: key);
- @override
- State<StatefulWidget> createState() {
- return AppNoticeState();
- }
- }
- class AppNoticeState extends State<AppNotice> {
- final pageController = PageController(initialPage: 0);
- int currPage = 0;
- @override
- Widget build(BuildContext context) {
- widget.pics.forEach((f) {
- precacheImage(Image.network(f).image, context);
- });
- return Material(
- color: Colors.transparent,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- SizedBox(
- width: double.infinity,
- height: (MediaQuery.of(context).size.width - 56) * 420 / 348,
- child: PageView(
- controller: pageController,
- onPageChanged: (page) {
- setState(() {
- currPage = page;
- });
- },
- children: widget.pics.map<Widget>((f) {
- return Container(
- height: (MediaQuery.of(context).size.width - 56) * 420 / 348,
- margin: EdgeInsets.only(left: 28, right: 28),
- child: SizedBox(
- child: ClipRRect(
- borderRadius: BorderRadius.circular(4),
- child: CachedNetworkImage(
- imageUrl: f,
- fit: BoxFit.cover,
- ),
- ),
- ),
- );
- }).toList(),
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: 20),
- child: GestureDetector(
- child: Image.asset(currPage == widget.pics.length - 1 ? 'images/icon_guanbi.png' : 'images/icon_next_page.png'),
- onTap: () {
- if (currPage == widget.pics.length - 1) {
- Navigator.of(context).pop();
- } else {
- pageController.nextPage(duration: Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
- }
- },
- ),
- )
- ],
- ),
- );
- }
- }
|