200 lines
6.1 KiB
Dart
200 lines
6.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:together_mobile/utils/init_get_it.dart';
|
|
import 'package:together_mobile/models/user_model.dart';
|
|
|
|
import 'package:together_mobile/screens/contact/components/friend_tile.dart';
|
|
import 'package:together_mobile/screens/contact/components/group_chat_tile.dart';
|
|
|
|
class ContactScreen extends StatefulWidget {
|
|
const ContactScreen({super.key});
|
|
|
|
@override
|
|
State<ContactScreen> createState() => _ContactScreenState();
|
|
}
|
|
|
|
class _ContactScreenState extends State<ContactScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Create a localkey, use to generate the custom scroll view,
|
|
// or there will be a error: "Duplicate GlobalKey detected in widget tree."
|
|
// But when I wrap custom scroll view into the RefrashIndicator, the key isn't needed any more
|
|
// const Key customScrollKey = ValueKey<String>('bottom-sliver-list');
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
leading: Row(
|
|
children: [
|
|
const SizedBox(
|
|
width: 8,
|
|
),
|
|
CircleAvatar(
|
|
backgroundImage: FileImage(
|
|
File(getIt.get<UserProfile>().avatar),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
title: const Text('通讯录'),
|
|
centerTitle: true,
|
|
actions: [
|
|
IconButton(
|
|
onPressed: () {},
|
|
icon: const Icon(Icons.search),
|
|
splashRadius: 20,
|
|
),
|
|
IconButton(
|
|
onPressed: () {
|
|
context.push('/contact/add');
|
|
},
|
|
icon: const Icon(Icons.person_add_alt_1),
|
|
splashRadius: 20,
|
|
),
|
|
],
|
|
),
|
|
body: RefreshIndicator(
|
|
onRefresh: () async {
|
|
await Future.delayed(const Duration(seconds: 2));
|
|
},
|
|
child: CustomScrollView(
|
|
physics: const BouncingScrollPhysics(),
|
|
// key: customScrollKey,
|
|
slivers: [
|
|
SliverFixedExtentList(
|
|
delegate: SliverChildListDelegate(
|
|
[
|
|
TextButton(
|
|
onPressed: () {
|
|
context.push('/contact/apply_list');
|
|
},
|
|
style: TextButton.styleFrom(
|
|
iconColor: Theme.of(context).textTheme.bodyLarge?.color,
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'添加申请',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color:
|
|
Theme.of(context).textTheme.bodyLarge?.color,
|
|
),
|
|
),
|
|
const Icon(
|
|
Icons.keyboard_arrow_right,
|
|
size: 30,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
context.push('/contact/friend_group');
|
|
},
|
|
style: TextButton.styleFrom(
|
|
iconColor: Theme.of(context).textTheme.bodyLarge?.color,
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'分组管理',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color:
|
|
Theme.of(context).textTheme.bodyLarge?.color,
|
|
),
|
|
),
|
|
const Icon(
|
|
Icons.keyboard_arrow_right,
|
|
size: 30,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
itemExtent: 50.0,
|
|
),
|
|
const SliverPersistentHeader(
|
|
delegate: _MySliverPersistentHeader(),
|
|
pinned: true,
|
|
),
|
|
SliverList(
|
|
delegate: SliverChildBuilderDelegate(
|
|
(
|
|
BuildContext context,
|
|
int index,
|
|
) =>
|
|
const FriendTile(),
|
|
childCount: 15,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
));
|
|
}
|
|
}
|
|
|
|
class _MySliverPersistentHeader extends SliverPersistentHeaderDelegate {
|
|
const _MySliverPersistentHeader();
|
|
|
|
@override
|
|
double get minExtent => 50;
|
|
|
|
@override
|
|
double get maxExtent => 50;
|
|
|
|
@override
|
|
Widget build(
|
|
BuildContext context,
|
|
double shrinkOffset,
|
|
bool overlapsContent,
|
|
) {
|
|
return Container(
|
|
height: 50,
|
|
color: Theme.of(context).colorScheme.background,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
TextButton(
|
|
onPressed: () {},
|
|
child: Text(
|
|
'分组',
|
|
style: TextStyle(
|
|
color: Theme.of(context).textTheme.bodyLarge?.color,
|
|
),
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () {},
|
|
child: Text(
|
|
'全部好友',
|
|
style: TextStyle(
|
|
color: Theme.of(context).textTheme.bodyLarge?.color,
|
|
),
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () {},
|
|
child: Text(
|
|
'群聊',
|
|
style: TextStyle(
|
|
color: Theme.of(context).textTheme.bodyLarge?.color,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
bool shouldRebuild(covariant _MySliverPersistentHeader oldDelegate) {
|
|
return false;
|
|
}
|
|
}
|