Skip to content

An open-source cross-platform alternative to AirDrop

feat: show name after one second

Tien Do Name4ebd571900c
diff --git a/lib/pages/send_page.dart b/lib/pages/send_page.dart
index 36866ce0..6d322590 100644
--- a/lib/pages/send_page.dart
+++ b/lib/pages/send_page.dart
@@ -6,6 +6,7 @@ import 'package:localsend_app/model/device.dart';
import 'package:localsend_app/model/session_status.dart';
import 'package:localsend_app/provider/device_info_provider.dart';
import 'package:localsend_app/provider/network/send_provider.dart';
+import 'package:localsend_app/util/sleep.dart';
import 'package:localsend_app/widget/device_list_tile.dart';
class SendPage extends ConsumerStatefulWidget {
@@ -19,6 +20,20 @@ class _SendPageState extends ConsumerState<SendPage> {
Device? _myDevice;
Device? _targetDevice;
+ // show name of sender after one second
+ bool _showName = false;
+
+ @override
+ void initState() {
+ super.initState();
+
+ sleepAsync(1000).then((value) {
+ if (mounted) {
+ setState(() => _showName = true);
+ }
+ });
+ }
+
@override
Widget build(BuildContext context) {
final sendState = ref.watch(sendProvider);
@@ -42,6 +57,7 @@ class _SendPageState extends ConsumerState<SendPage> {
tag: 'this-device',
child: DeviceListTile(
device: myDevice,
+ thisDevice: !_showName,
),
),
const SizedBox(height: 20),
diff --git a/lib/widget/device_list_tile.dart b/lib/widget/device_list_tile.dart
index ec330b1c..1a9c2ac3 100644
--- a/lib/widget/device_list_tile.dart
+++ b/lib/widget/device_list_tile.dart
@@ -31,7 +31,13 @@ class DeviceListTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FittedBox(
- child: Text(thisDevice ? t.send.thisDevice : device.alias, style: const TextStyle(fontSize: 20)),
+ child: AnimatedCrossFade(
+ crossFadeState: thisDevice ? CrossFadeState.showFirst : CrossFadeState.showSecond,
+ alignment: Alignment.topLeft,
+ duration: const Duration(milliseconds: 200),
+ firstChild: Text(t.send.thisDevice, style: const TextStyle(fontSize: 20)),
+ secondChild: Text(device.alias, style: const TextStyle(fontSize: 20)),
+ ),
),
const SizedBox(height: 5),
Wrap(