diff --git a/lib/screens/activity_list_screen.dart b/lib/screens/activity_list_screen.dart index 0712784..4e79932 100644 --- a/lib/screens/activity_list_screen.dart +++ b/lib/screens/activity_list_screen.dart @@ -65,7 +65,17 @@ class _ActivityListScreenState extends State { }, ]; + Future _refreshActivities() async { + await Future.delayed(Duration(seconds: 1)); + if (!mounted) return; + setState(() {}); + } + void _onItemTapped(int index) { + if (index == 0 && _selectedIndex == 0) { + _refreshActivities(); + return; + } if (index == 2) { // 中间按钮 - 跳转到发布页面 Navigator.push( @@ -81,9 +91,11 @@ class _ActivityListScreenState extends State { ); return; } - setState(() { - _selectedIndex = index; - }); + if (_selectedIndex != index) { + setState(() { + _selectedIndex = index; + }); + } } @override @@ -113,10 +125,7 @@ class _ActivityListScreenState extends State { Widget _buildBody() { return RefreshIndicator( - onRefresh: () async { - await Future.delayed(Duration(seconds: 1)); - setState(() {}); - }, + onRefresh: _refreshActivities, child: Padding( padding: EdgeInsets.all(8), child: MasonryGridView.count( diff --git a/lib/screens/messages_screen.dart b/lib/screens/messages_screen.dart index 769963c..0ab6b31 100644 --- a/lib/screens/messages_screen.dart +++ b/lib/screens/messages_screen.dart @@ -22,91 +22,98 @@ class MessagesScreen extends StatelessWidget { padding: const EdgeInsets.all(16), itemCount: _mockMessages.length, separatorBuilder: (_, __) => const SizedBox(height: 10), - itemBuilder: (context, index) => _buildMessageTile(_mockMessages[index]), + itemBuilder: (context, index) => _buildMessageTile(context, _mockMessages[index]), ), ); } - Widget _buildMessageTile(Map message) { + Widget _buildMessageTile(BuildContext context, Map message) { final unread = message['unread'] as int; - return InkWell( - borderRadius: BorderRadius.circular(14), - onTap: () { - // TODO: 跳转会话详情页 - }, - child: Container( - padding: const EdgeInsets.all(12), + return Material( + color: Colors.transparent, + child: Ink( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(14), ), - child: Row( - children: [ - CircleAvatar( - radius: 24, - backgroundColor: const Color(0xFFFFE7CF), - backgroundImage: NetworkImage('https://i.pravatar.cc/50?img=${message['avatar']}'), - ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - message['name'] as String, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w700, - color: Color(0xFF333333), - ), - ), - const SizedBox(height: 4), - Text( - message['preview'] as String, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 14, - color: Color(0xFF8A8A8A), - ), - ), - ], - ), - ), - const SizedBox(width: 12), - Column( - crossAxisAlignment: CrossAxisAlignment.end, + child: InkWell( + borderRadius: BorderRadius.circular(14), + onTap: () { + ScaffoldMessenger.of(context) + ..hideCurrentSnackBar() + ..showSnackBar(const SnackBar(content: Text('功能开发中,敬请期待'))); + }, + child: Padding( + padding: const EdgeInsets.all(12), + child: Row( children: [ - Text( - message['time'] as String, - style: const TextStyle( - fontSize: 12, - color: Color(0xFF999999), + CircleAvatar( + radius: 24, + backgroundColor: const Color(0xFFFFE7CF), + backgroundImage: NetworkImage('https://i.pravatar.cc/50?img=${message['avatar']}'), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + message['name'] as String, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w700, + color: Color(0xFF333333), + ), + ), + const SizedBox(height: 4), + Text( + message['preview'] as String, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 14, + color: Color(0xFF8A8A8A), + ), + ), + ], ), ), - const SizedBox(height: 8), - unread > 0 - ? Container( - width: 18, - height: 18, - decoration: const BoxDecoration( - color: Color(0xFFFF4D4F), - shape: BoxShape.circle, - ), - alignment: Alignment.center, - child: Text( - '$unread', - style: const TextStyle( - color: Colors.white, - fontSize: 10, - fontWeight: FontWeight.w700, - ), - ), - ) - : const SizedBox(height: 18), + const SizedBox(width: 12), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + message['time'] as String, + style: const TextStyle( + fontSize: 12, + color: Color(0xFF999999), + ), + ), + const SizedBox(height: 8), + unread > 0 + ? Container( + width: 18, + height: 18, + decoration: const BoxDecoration( + color: Color(0xFFFF4D4F), + shape: BoxShape.circle, + ), + alignment: Alignment.center, + child: Text( + '$unread', + style: const TextStyle( + color: Colors.white, + fontSize: 10, + fontWeight: FontWeight.w700, + ), + ), + ) + : const SizedBox(height: 18), + ], + ), ], ), - ], + ), ), ), ); diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart index 8d8acb2..86e3e4c 100644 --- a/lib/screens/profile_screen.dart +++ b/lib/screens/profile_screen.dart @@ -41,11 +41,11 @@ class _ProfileScreenState extends State { } Future _openProfileSetup() async { - await Navigator.push( - context, + await Navigator.of(context).push( MaterialPageRoute(builder: (_) => const ProfileSetupScreen()), ); - _loadProfile(); + if (!mounted) return; + await _loadProfile(); } @override diff --git a/pubspec.yaml b/pubspec.yaml index 1a8bd89..a12c8d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: banxiang_app description: 伴享 -version: 1.1.2+4 +version: 1.1.3+5 environment: sdk: '>=3.0.0 <4.0.0' diff --git a/releases/banxiang-v1.1.3+5.apk b/releases/banxiang-v1.1.3+5.apk new file mode 100644 index 0000000..ad07455 Binary files /dev/null and b/releases/banxiang-v1.1.3+5.apk differ