💄 Better friend page loading indicator
This commit is contained in:
		| @@ -2,7 +2,6 @@ import 'dart:async'; | |||||||
|  |  | ||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| import 'package:get/get.dart'; | import 'package:get/get.dart'; | ||||||
| import 'package:get/get_rx/get_rx.dart'; |  | ||||||
| import 'package:livekit_client/livekit_client.dart'; | import 'package:livekit_client/livekit_client.dart'; | ||||||
| import 'package:permission_handler/permission_handler.dart'; | import 'package:permission_handler/permission_handler.dart'; | ||||||
| import 'package:solian/models/call.dart'; | import 'package:solian/models/call.dart'; | ||||||
|   | |||||||
| @@ -1,9 +1,9 @@ | |||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| import 'package:flutter_animate/flutter_animate.dart'; |  | ||||||
| import 'package:get/get.dart'; | import 'package:get/get.dart'; | ||||||
| import 'package:solian/exts.dart'; | import 'package:solian/exts.dart'; | ||||||
| import 'package:solian/models/relations.dart'; | import 'package:solian/models/relations.dart'; | ||||||
| import 'package:solian/providers/relation.dart'; | import 'package:solian/providers/relation.dart'; | ||||||
|  | import 'package:solian/theme.dart'; | ||||||
| import 'package:solian/widgets/account/relative_list.dart'; | import 'package:solian/widgets/account/relative_list.dart'; | ||||||
|  |  | ||||||
| class FriendScreen extends StatefulWidget { | class FriendScreen extends StatefulWidget { | ||||||
| @@ -21,15 +21,15 @@ class _FriendScreenState extends State<FriendScreen> | |||||||
|  |  | ||||||
|   List<Relationship> _relations = List.empty(); |   List<Relationship> _relations = List.empty(); | ||||||
|  |  | ||||||
|   List<Relationship> filterByStatus(int status) { |   List<Relationship> _filterByStatus(int status) { | ||||||
|     return _relations.where((x) => x.status == status).toList(); |     return _relations.where((x) => x.status == status).toList(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Future<void> loadRelations() async { |   Future<void> _loadRelations() async { | ||||||
|     setState(() => _isBusy = true); |     setState(() => _isBusy = true); | ||||||
|  |  | ||||||
|     final RelationshipProvider provider = Get.find(); |     final RelationshipProvider relations = Get.find(); | ||||||
|     final resp = await provider.listRelation(); |     final resp = await relations.listRelation(); | ||||||
|  |  | ||||||
|     setState(() { |     setState(() { | ||||||
|       _relations = resp.body |       _relations = resp.body | ||||||
| @@ -104,8 +104,8 @@ class _FriendScreenState extends State<FriendScreen> | |||||||
|     super.initState(); |     super.initState(); | ||||||
|     _tabController = TabController(length: 3, vsync: this); |     _tabController = TabController(length: 3, vsync: this); | ||||||
|  |  | ||||||
|     loadRelations().then((_) { |     _loadRelations().then((_) { | ||||||
|       if (filterByStatus(0).isEmpty) { |       if (_filterByStatus(0).isEmpty) { | ||||||
|         _tabController.animateTo(1); |         _tabController.animateTo(1); | ||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
| @@ -119,6 +119,19 @@ class _FriendScreenState extends State<FriendScreen> | |||||||
|         appBar: AppBar( |         appBar: AppBar( | ||||||
|           centerTitle: false, |           centerTitle: false, | ||||||
|           title: Text('accountFriend'.tr), |           title: Text('accountFriend'.tr), | ||||||
|  |           actions: [ | ||||||
|  |             if (_isBusy) | ||||||
|  |               SizedBox( | ||||||
|  |                 height: 48, | ||||||
|  |                 width: 48, | ||||||
|  |                 child: const CircularProgressIndicator( | ||||||
|  |                   strokeWidth: 3, | ||||||
|  |                 ).paddingAll(14), | ||||||
|  |               ), | ||||||
|  |             SizedBox( | ||||||
|  |               width: SolianTheme.isLargeScreen(context) ? 8 : 16, | ||||||
|  |             ), | ||||||
|  |           ], | ||||||
|           bottom: TabBar( |           bottom: TabBar( | ||||||
|             controller: _tabController, |             controller: _tabController, | ||||||
|             tabs: const [ |             tabs: const [ | ||||||
| @@ -136,46 +149,34 @@ class _FriendScreenState extends State<FriendScreen> | |||||||
|           controller: _tabController, |           controller: _tabController, | ||||||
|           children: [ |           children: [ | ||||||
|             RefreshIndicator( |             RefreshIndicator( | ||||||
|               onRefresh: () => loadRelations(), |               onRefresh: () => _loadRelations(), | ||||||
|               child: CustomScrollView( |               child: CustomScrollView( | ||||||
|                 slivers: [ |                 slivers: [ | ||||||
|                   if (_isBusy) |  | ||||||
|                     SliverToBoxAdapter( |  | ||||||
|                       child: const LinearProgressIndicator().animate().scaleX(), |  | ||||||
|                     ), |  | ||||||
|                   SilverRelativeList( |                   SilverRelativeList( | ||||||
|                     items: filterByStatus(0), |                     items: _filterByStatus(0), | ||||||
|                     onUpdate: () => loadRelations(), |                     onUpdate: () => _loadRelations(), | ||||||
|                   ), |                   ), | ||||||
|                 ], |                 ], | ||||||
|               ), |               ), | ||||||
|             ), |             ), | ||||||
|             RefreshIndicator( |             RefreshIndicator( | ||||||
|               onRefresh: () => loadRelations(), |               onRefresh: () => _loadRelations(), | ||||||
|               child: CustomScrollView( |               child: CustomScrollView( | ||||||
|                 slivers: [ |                 slivers: [ | ||||||
|                   if (_isBusy) |  | ||||||
|                     SliverToBoxAdapter( |  | ||||||
|                       child: const LinearProgressIndicator().animate().scaleX(), |  | ||||||
|                     ), |  | ||||||
|                   SilverRelativeList( |                   SilverRelativeList( | ||||||
|                     items: filterByStatus(1), |                     items: _filterByStatus(1), | ||||||
|                     onUpdate: () => loadRelations(), |                     onUpdate: () => _loadRelations(), | ||||||
|                   ), |                   ), | ||||||
|                 ], |                 ], | ||||||
|               ), |               ), | ||||||
|             ), |             ), | ||||||
|             RefreshIndicator( |             RefreshIndicator( | ||||||
|               onRefresh: () => loadRelations(), |               onRefresh: () => _loadRelations(), | ||||||
|               child: CustomScrollView( |               child: CustomScrollView( | ||||||
|                 slivers: [ |                 slivers: [ | ||||||
|                   if (_isBusy) |  | ||||||
|                     SliverToBoxAdapter( |  | ||||||
|                       child: const LinearProgressIndicator().animate().scaleX(), |  | ||||||
|                     ), |  | ||||||
|                   SilverRelativeList( |                   SilverRelativeList( | ||||||
|                     items: filterByStatus(3), |                     items: _filterByStatus(3), | ||||||
|                     onUpdate: () => loadRelations(), |                     onUpdate: () => _loadRelations(), | ||||||
|                   ), |                   ), | ||||||
|                 ], |                 ], | ||||||
|               ), |               ), | ||||||
|   | |||||||
| @@ -58,6 +58,7 @@ class _AttachmentListState extends State<AttachmentList> { | |||||||
|         _attachmentsMeta = result; |         _attachmentsMeta = result; | ||||||
|         _isLoading = false; |         _isLoading = false; | ||||||
|       }); |       }); | ||||||
|  |       _calculateAspectRatio(); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user