| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import 'package:flutter/material.dart';
- import 'package:prime_chat/basic/Entities.dart';
- import 'package:prime_chat/screens/AddFriendScreen.dart';
- import 'package:prime_chat/screens/components/Avatar.dart';
- import 'package:prime_chat/screens/components/UserProfileCard.dart';
- import '../basic/Method.dart';
- import 'ChatScreen.dart';
- class ProfileScreen extends StatelessWidget {
- const ProfileScreen({Key? key, required this.profile, required this.isFriend})
- : super(key: key);
- final bool isFriend;
- final Profile profile;
- @override
- Widget build(BuildContext context) {
- List<Widget> children = [
- UserProfileCard(load: () async => profile),
- const Divider(),
- ];
- if (isFriend) {
- children
- .add(_buildItem(context, Icons.messenger_outline, "发消息", onTap: () {
- Navigator.push(context,
- MaterialPageRoute(builder: (context) => ChatScreen(profile, method.directRoomId(profile.id))));
- }));
- } else {
- children.add(_buildItem(context, Icons.person_add_alt_outlined, "加好友", onTap: () {
- Navigator.push(context,
- MaterialPageRoute(builder: (context) => AddFriendScreen(profile)));
- }));
- }
- return Scaffold(
- appBar: AppBar(),
- body: Column(children: children),
- );
- }
- Widget _buildItem(BuildContext context, IconData icon, String title,
- {void Function()? onTap}) {
- return InkWell(
- onTap: onTap,
- child: Center(
- child: Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Icon(
- icon,
- ),
- const SizedBox(
- width: 10,
- height: 50,
- ),
- Text(
- title,
- style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w300),
- ),
- ])),
- );
- }
- }
|