From b618fcc6da98ebbfca2566e652d375890491cf72 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 14 Dec 2024 01:36:23 +0800 Subject: [PATCH] :bug: Bug fixes on somewhere --- lib/main.dart | 2 ++ lib/screens/chat/room.dart | 4 +--- .../navigation/app_drawer_navigation.dart | 10 ++-------- lib/widgets/post/post_item.dart | 5 ++++- lib/widgets/version_label.dart | 20 +++++++++++++++++++ 5 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 lib/widgets/version_label.dart diff --git a/lib/main.dart b/lib/main.dart index d61d3ac..4e815b5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,6 +32,7 @@ import 'package:surface/types/chat.dart'; import 'package:surface/types/realm.dart'; import 'package:flutter_web_plugins/url_strategy.dart' show usePathUrlStrategy; import 'package:surface/widgets/dialog.dart'; +import 'package:surface/widgets/version_label.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -196,6 +197,7 @@ class _AppSplashScreenState extends State<_AppSplashScreen> { ), const Gap(20), Text('appInitializing'.tr(), textAlign: TextAlign.center), + AppVersionLabel(), ], ), ).center(), diff --git a/lib/screens/chat/room.dart b/lib/screens/chat/room.dart index 3f86961..3458071 100644 --- a/lib/screens/chat/room.dart +++ b/lib/screens/chat/room.dart @@ -1,6 +1,4 @@ import 'dart:async'; -import 'dart:convert'; -import 'dart:developer'; import 'package:dio/dio.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -111,7 +109,7 @@ class _ChatRoomScreenState extends State { try { final sn = context.read(); - final resp = await sn.client.post( + await sn.client.post( '/cgi/im/channels/${_messageController.channel!.keyPath}/calls', options: Options( sendTimeout: const Duration(seconds: 30), diff --git a/lib/widgets/navigation/app_drawer_navigation.dart b/lib/widgets/navigation/app_drawer_navigation.dart index 7c51e9d..8faa623 100644 --- a/lib/widgets/navigation/app_drawer_navigation.dart +++ b/lib/widgets/navigation/app_drawer_navigation.dart @@ -6,6 +6,7 @@ import 'package:provider/provider.dart'; import 'package:responsive_framework/responsive_framework.dart'; import 'package:styled_widget/styled_widget.dart'; import 'package:surface/providers/navigation.dart'; +import 'package:surface/widgets/version_label.dart'; class AppNavigationDrawer extends StatefulWidget { final double? elevation; @@ -49,14 +50,7 @@ class _AppNavigationDrawerState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Solar Network').bold(), - FutureBuilder( - future: PackageInfo.fromPlatform().then((value) => 'Stable ${value.version}+${value.buildNumber}'), - builder: (context, snapshot) { - return Text(!snapshot.hasData ? 'Stable 2.0' : snapshot.data!) - .fontSize(12) - .textColor(Theme.of(context).colorScheme.onSurface.withOpacity(0.5)); - }, - ), + AppVersionLabel(), ], ).padding( horizontal: 32, diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 65ae5b0..ea462f9 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -203,6 +203,7 @@ class PostItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ _PostContentHeader( + isAuthor: isAuthor, data: data, showMenu: showMenu, onShare: () => _doShare(context), @@ -299,6 +300,7 @@ class PostShareImageWidget extends StatelessWidget { ), ).padding(bottom: 8), _PostContentHeader( + isAuthor: false, data: data, onDeleted: () {}, onShare: () {}, @@ -629,7 +631,7 @@ class _PostContentHeader extends StatelessWidget { const _PostContentHeader({ required this.data, - this.isAuthor = false, + required this.isAuthor, this.isCompact = false, this.isRelativeDate = true, this.showMenu = true, @@ -894,6 +896,7 @@ class _PostQuoteContent extends StatelessWidget { Column( children: [ _PostContentHeader( + isAuthor: false, data: child, isCompact: true, isRelativeDate: isRelativeDate, diff --git a/lib/widgets/version_label.dart b/lib/widgets/version_label.dart new file mode 100644 index 0000000..8144a99 --- /dev/null +++ b/lib/widgets/version_label.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:styled_widget/styled_widget.dart'; + +class AppVersionLabel extends StatelessWidget { + final double fontSize; + const AppVersionLabel({super.key, this.fontSize = 12}); + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: PackageInfo.fromPlatform().then((value) => 'Stable ${value.version}+${value.buildNumber}'), + builder: (context, snapshot) { + return Text(!snapshot.hasData ? 'Stable 2.0' : snapshot.data!).fontSize(fontSize).textColor( + Theme.of(context).colorScheme.onSurface.withOpacity(0.5), + ); + }, + ); + } +}