redeem_query_view.dart 3.4 KB
import 'dart:math';
import 'package:cp_offline_manage/common/colors.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'redeem_query_logic.dart';

class Redeem_queryPage extends GetView<Redeem_queryLogic> {
  const Redeem_queryPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: GetBuilder<Redeem_queryLogic>(builder: (logic) {
            return Text('${controller.queryStr}兑奖金额汇总');
          }),
          centerTitle: true,
          backgroundColor: ColorConfig.themeColor,
          actions: [
            Container(
              alignment: Alignment.center,
              margin: const EdgeInsets.only(right: 20),
              child: InkWell(
                child: Image(
                  image: AssetImage("assets/images/home_icon/icon_filter_dwm.png"),
                  width: 24,
                  height: 24,
                ),
                onTap: () {
                  showDialog(context: context, builder: _showFilterView);
                },
              ),
            )
          ],
        ),
        body: Container(
            child: ListView.builder(
          itemBuilder: (item, index) {
            return InkWell(
              onTap: () {
                controller.jumpToDetail('体育路${index + 1}门店');
              },
              child: Container(
                alignment: Alignment.centerLeft,
                padding: EdgeInsets.symmetric(horizontal: 16),
                height: 64,
                child: Row(
                  children: [
                    Expanded(
                        child: Row(
                      children: [
                        Text('体育路${index + 1}门店'),
                        Expanded(child: Container()),
                        GetBuilder<Redeem_queryLogic>(builder: (logic) {
                          return Text(
                            '${500 * Random().nextInt(101)}元',
                            style: TextStyle(color: Colors.green),
                          );
                        }),
                      ],
                    )),
                    SizedBox(
                      width: 20,
                    ),
                    Icon(
                      Icons.chevron_right,
                      size: 24,
                      color: ColorConfig.color99,
                    )
                  ],
                ),
                decoration: BoxDecoration(
                    border: Border(
                        bottom: BorderSide(
                            width: .5, color: ColorConfig.colorCcc))),
              ),
            );
          },
          itemCount: 20,
        )));
  }

  // 过滤选项弹框
  Widget _showFilterView(BuildContext context) {
    return GetBuilder<Redeem_queryLogic>(builder: (logic) {
      return AlertDialog(
        content: SingleChildScrollView(
          child: ListBody(
              children: List.generate(controller.queryOptions.length, (index) {
            var item = controller.queryOptions[index];
            return CheckboxListTile(
              title: Text("${item["queryName"]}"),
              value: item["value"],
              onChanged: (newValue) {
                controller.updateQueryStr(index);
                Navigator.of(context).pop();
              },
            );
          })),
        ),
      );
    });
  }
}