Rannie / flui

A powerful UI framework for Google Flutter.
https://www.flui.xin/en/
MIT License
1.47k stars 136 forks source link

FLStaticListView 使用,当sections元素很多的时候不能支持页面滚动吗? #35

Open jcleng opened 4 years ago

jcleng commented 4 years ago

测试源码

import 'package:flui/flui.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

/// 用户中心页面
class UserSettingPage extends StatefulWidget {
  UserSettingPage({Key key}) : super(key: key);

  @override
  _UserSettingPageState createState() => _UserSettingPageState();
}

class _UserSettingPageState extends State<UserSettingPage> with RouteAware {
  // 点击底部退出按钮
  willSelectLogout() {
    showDialog(
      context: context,
      barrierDismissible: false,
      builder: (BuildContext context) {
        return AlertDialog(
          content: SingleChildScrollView(
            child: ListBody(
              children: <Widget>[
                Padding(
                  padding: EdgeInsets.only(top: 40),
                ),
                GestureDetector(
                  onTap: () {},
                  child: Text('   退出登录'),
                ),
                Padding(
                  padding: EdgeInsets.only(bottom: 20),
                ),
                Padding(
                  padding: EdgeInsets.only(bottom: 20),
                ),
                GestureDetector(
                  onTap: () async {
                    await SystemChannels.platform
                        .invokeMethod('SystemNavigator.pop');
                  },
                  child: Text('   退出程序'),
                ),
              ],
            ),
          ),
          actions: <Widget>[
            FlatButton(
              child: Text('取消'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    ).then((val) {
      print(val);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: FLAppBarTitle(
          title: '设置',
          // subtitle: '(subtitle)',
        ),
        centerTitle: true,
      ),
      body: Container(
        child: ListView(
          children: [
            // 头像
            Container(
              child: Column(
                children: [
                  Padding(padding: EdgeInsets.only(top: 23)),
                  GestureDetector(
                    child: Container(
                        width: 80,
                        height: 80,
                        decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          borderRadius: BorderRadius.circular(80),
                          image: DecorationImage(
                              image: NetworkImage(
                                  'https://www.dogedoge.com/rmt/QjmnZnf7-99_14oATuI2m-o6Gl5lNXUKPLEVtOSdermAm8fTGOx8mchN4?w=212&h=130'),
                              fit: BoxFit.cover),
                        )),
                    onTap: () {},
                  ),
                  Padding(padding: EdgeInsets.only(bottom: 20)),
                  GestureDetector(
                    onTap: () {},
                    child: Text(
                      '点击修改头像',
                      style: TextStyle(fontSize: 12, color: Color(0xFF999999)),
                    ),
                  )
                ],
              ),
            ),
            FLStaticListView(
              shrinkWrap: true,
              sections: [
                FLStaticSectionData(headerTitle: '账号', itemList: [
                  FLStaticItemData(
                      title: '账号管理',
                      accessoryType: FLStaticListCellAccessoryType.accDetail,
                      onTap: null),
                  FLStaticItemData(
                      title: '账号与安全',
                      accessoryType: FLStaticListCellAccessoryType.accDetail,
                      onTap: null),
                ]),
                FLStaticSectionData(headerTitle: '设置', itemList: [
                  FLStaticItemData(
                      title: '推送通知设置',
                      accessoryType: FLStaticListCellAccessoryType.accDetail,
                      accessoryString: '全部通知',
                      onTap: () => {}),
                  FLStaticItemData(
                    title: '护眼模式',
                    accessoryType: FLStaticListCellAccessoryType.accSwitch,
                    accItemValue: true,
                    onButtonPressed: () {
                      print('onButtonPressed');
                    },
                    onTap: () => {print('onTap')},
                  ),
                  FLStaticItemData(
                    title: '自动清理缓存',
                    subtitle: '每 10 天清理一次',
                    accessoryType: FLStaticListCellAccessoryType.accCheckmark,
                    onTap: null,
                    selected: false,
                  )
                ]),
                FLStaticSectionData(itemList: [
                  FLStaticItemData(
                      cellType: FLStaticListCellType.button,
                      buttonTitle: '退出登录',
                      buttonTitleColor: Colors.blue,
                      onButtonPressed: () {
                        print('button pressed');
                      }),
                  FLStaticItemData(
                      cellType: FLStaticListCellType.button,
                      buttonTitle: '退出程序',
                      buttonTitleColor: Colors.red,
                      onButtonPressed: () {
                        willSelectLogout();
                      })
                ])
              ],
            ),
          ],
        ),
      ),
    );
  }
}
Rannie commented 4 years ago

@jcleng ok 我会跟进下