diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index a97d2be..2ae89b7 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -285,7 +285,7 @@ class _ChatScreenState extends State { ), Gap(15), Text( - "Search message...", + "搜索信息", style: TextStyle( fontSize: 18, color: Color.fromARGB(255, 128, 128, 128), diff --git a/lib/screens/message_screen.dart b/lib/screens/message_screen.dart index 7a99dde..42009e2 100644 --- a/lib/screens/message_screen.dart +++ b/lib/screens/message_screen.dart @@ -361,21 +361,21 @@ class _MessageScreenState extends State { ), VerticalDivider(color: Colors.black.withOpacity(0.2)), const Gap(15), - Row( - children: [ - Icon( - Icons.mood, - size: 25, - color: Colors.black.withOpacity(0.5), - ), - const Gap(17), - Icon( - Icons.photo_camera, - size: 25, - color: Colors.black.withOpacity(0.5), - ), - ], - ), + // Row( + // children: [ + // Icon( + // Icons.mood, + // size: 25, + // color: Colors.black.withOpacity(0.5), + // ), + // const Gap(17), + // Icon( + // Icons.photo_camera, + // size: 25, + // color: Colors.black.withOpacity(0.5), + // ), + // ], + // ), ], ), ), diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart index 5537a47..672a42c 100644 --- a/lib/screens/profile_screen.dart +++ b/lib/screens/profile_screen.dart @@ -1,9 +1,13 @@ // ignore_for_file: use_build_context_synchronously +import 'dart:typed_data'; + import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import '../screens/welcome_screen.dart'; import 'package:matrix/matrix.dart'; +import 'package:image_picker/image_picker.dart'; +import 'dart:io'; import '../utils/dialogs.dart'; import 'package:hanhai/main.dart'; @@ -19,13 +23,25 @@ class _ProfileScreenState extends State { int i = 0; String? user = "default"; Uri? url; + void _changeAvatarChoser() async { + final ImagePicker picker = ImagePicker(); + final XFile? response = await picker.pickImage(source: ImageSource.gallery); + if (response==null) { + return; + } + //final List? files = response.files; + String filePath = response.path; + Uint8List uint8list = await File(filePath).readAsBytes(); + widget.client.setAvatar(MatrixImageFile(bytes: uint8list, name: widget.client.clientName.toString())); + } logout() async { questionDialog( context: context, - title: "Logout", - content: "Are you sure want to logout from your account?", + title: "登出", + content: "你确定要登出你的账户吗", func: () async { + final client = widget.client; await client.logout(); Navigator.of(context).pushAndRemoveUntil( @@ -36,7 +52,7 @@ class _ProfileScreenState extends State { ); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("You are successfully logged out."), + content: Text("你已成功登出"), backgroundColor: Colors.green, ), ); @@ -88,7 +104,7 @@ class _ProfileScreenState extends State { appBar: AppBar( title: const Center( child: Text( - "My Profile", + "个人中心", ), ), ), @@ -128,20 +144,25 @@ class _ProfileScreenState extends State { ), ), ), + Center(child: TextButton(onPressed: _changeAvatarChoser, child: const Text("更改头像")),), const Gap(20), const Divider(thickness: 2, endIndent: 15, indent: 15), const Gap(20), - Text( - user!, + Center(child: Container(width: 250,child: TextField( + textAlign: TextAlign.center, + decoration: InputDecoration(hintText: user!), + onSubmitted: (value) async { + await widget.client.setDisplayName(widget.client.userID!, value); + }, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), - ), - Text( - "@${user!}", - style: const TextStyle(fontSize: 15), - ), + ),),), + // Text( + // "@${widget.client.userID!}", + // style: const TextStyle(fontSize: 15), + // ), const Gap(20), const Divider(thickness: 2, endIndent: 15, indent: 15), const Gap(20), @@ -214,7 +235,7 @@ class _ProfileScreenState extends State { Icon(Icons.logout_outlined, size: 28), Gap(10), Text( - "Log Out", + "登出", style: TextStyle(fontSize: 20), ), ], diff --git a/pubspec.yaml b/pubspec.yaml index 09a6cf6..b26ec2a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 3.0.0+2 +version: 3.9.0+1 environment: sdk: '>=3.3.3 <4.0.0'