123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart' hide NestedScrollView;
- import 'package:flutter_easyrefresh/easy_refresh.dart';
- import 'package:sport/bean/post_user.dart';
- import 'package:sport/bean/user_info.dart';
- import 'package:sport/provider/lib/provider_widget.dart';
- import 'package:sport/provider/lib/simple_model.dart';
- import 'package:sport/provider/lib/view_state_lifecycle.dart';
- import 'package:sport/router/navigator_util.dart';
- import 'package:sport/services/api/inject_api.dart';
- import 'package:sport/utils/DateFormat.dart';
- import 'package:sport/widgets/appbar.dart';
- import 'package:sport/widgets/dialog/request_dialog.dart';
- import 'package:sport/widgets/error.dart';
- import 'package:sport/widgets/image.dart';
- import 'package:sport/widgets/loading.dart';
- import 'package:sport/widgets/misc.dart';
- class BlockUserListPage extends StatefulWidget {
- @override
- State<StatefulWidget> createState() => _PageDetailState();
- }
- class _PageDetailState
- extends ViewStateLifecycle<BlockUserListPage, SimpleModel> with InjectApi {
- late TextEditingController _controller;
- late FocusNode _focusNode;
- @override
- void initState() {
- super.initState();
- _focusNode = FocusNode();
- _controller = new TextEditingController(text: '');
- }
- @override
- void dispose() {
- super.dispose();
- _focusNode.dispose();
- _controller.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.white,
- appBar: buildAppBar(context, title: "屏蔽列表"),
- body: ProviderWidget<SimpleModel>(
- model: model,
- onModelReady: (model) => model.initData(),
- builder: (_, model, __) {
- return EasyRefresh.custom(
- onRefresh: () => model.refresh(),
- enableControlFinishRefresh: true,
- enableControlFinishLoad: true,
- controller: model.refreshController,
- header: buildClassicalHeader(),
- footer: buildClassicalFooter(),
- slivers: <Widget>[
- SliverToBoxAdapter(
- child: _searchWidget(),
- ),
- if (model.isBusy)
- SliverToBoxAdapter(
- child: RequestLoadingWidget(),
- ),
- if (model.isEmpty)
- SliverToBoxAdapter(
- child: RequestErrorWidget(
- null,
- msg: "暂无用户~",
- ),
- ),
- if (model.isIdle)
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return _buildItem(model.list[index]);
- },
- childCount: model.list.length,
- ),
- ),
- if (model.isError)
- SliverToBoxAdapter(
- child: RequestErrorWidget(() {
- model.initData();
- }),
- ),
- ],
- );
- }),
- );
- }
- Widget _buildItem(UserInfo user) {
- return Column(
- children: <Widget>[
- Padding(
- padding: const EdgeInsets.all(12.0),
- child: InkWell(
- onTap: () => NavigatorUtil.goSocialUserDetail(
- context,
- PostUser(
- id: "${user.id}",
- name: user.name,
- avatar: user.avatar)),
- child: Row(
- children: <Widget>[
- CircleAvatar(
- backgroundColor: Colors.black26,
- backgroundImage: userAvatarProvider(user.avatar),
- radius: 22,
- ),
- SizedBox(
- width: 8,
- ),
- Expanded(
- child: Text(
- "${user.name}",
- style: Theme.of(context).textTheme.headline3,
- ),
- ),
- GestureDetector(
- child: Container(
- width: 82,
- height: 30,
- alignment: Alignment.center,
- child: Text(
- "取消屏蔽",
- strutStyle: fixedLine,
- style: Theme.of(context).textTheme.bodyText2!,
- ),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- border: Border.all(
- color: Color(0xff999999),
- width: .5,
- ),
- ),
- ),
- onTap: () async {
- await request(context, () async {
- var resp = await api
- .postForumUnBlockUser("${user.id}")
- .catchError((onError) {});
- if (resp.code == 0) {
- setState(() {
- model.list.remove(user);
- });
- }
- });
- },
- )
- ],
- )),
- ),
- Divider(
- height: 1,
- )
- ],
- );
- }
- Widget _searchWidget() {
- return Container(
- margin: EdgeInsets.fromLTRB(12.0, 6.0, 12.0, 6.0),
- height: 40,
- padding: EdgeInsets.fromLTRB(12.0, 0, 12.0, 0),
- decoration: BoxDecoration(
- color: Color(0xffF1F1F1),
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.all(Radius.circular(50)),
- ),
- child: Row(
- children: <Widget>[
- Image.asset("lib/assets/img/searchbar_icon_search.png"),
- SizedBox(
- width: 6,
- ),
- Expanded(
- child: CupertinoTextField(
- cursorColor: const Color(0xffFFC400),
- controller: _controller,
- maxLines: 1,
- focusNode: _focusNode,
- placeholder: "输入帐号/用户昵称",
- placeholderStyle: Theme.of(context).textTheme.bodyText2,
- decoration: BoxDecoration(
- // 文本框装饰
- color: Colors.transparent, // 文本框颜色
- ),
- onChanged: (value) {},
- onSubmitted: (value) {},
- ),
- ),
- ],
- ),
- );
- }
- @override
- SimpleModel createModel() =>
- SimpleModel((page) async => (await api.getMyBlockUsers()).results);
- }
|