diff --git a/lib/screens/contacts_screen.dart b/lib/screens/contacts_screen.dart index 47e0dd7..9679c9a 100644 --- a/lib/screens/contacts_screen.dart +++ b/lib/screens/contacts_screen.dart @@ -5,9 +5,7 @@ import 'package:provider/provider.dart'; import '../controls/app_bottom_nav_bar.dart'; import '../controls/current_profile_button.dart'; -import '../controls/padding.dart'; import '../controls/standard_app_drawer.dart'; -import '../controls/status_and_refresh_button.dart'; import '../globals.dart'; import '../models/connection.dart'; import '../routes.dart'; @@ -45,10 +43,11 @@ class _ContactsScreenState extends State { ); late Widget body; if (contacts.isEmpty) { - body = const SingleChildScrollView( - physics: AlwaysScrollableScrollPhysics(), - child: Text('No Contacts'), - ); + body = SingleChildScrollView( + physics: AlwaysScrollableScrollPhysics(), + child: Center( + child: Text('No contacts'), + )); } else { body = ListView.separated( physics: const AlwaysScrollableScrollPhysics(), @@ -66,67 +65,58 @@ class _ContactsScreenState extends State { separatorBuilder: (context, index) => const Divider(), itemCount: contacts.length); } - final profileButton = buildCurrentProfileButton(context); - return Scaffold( - drawer: StandardAppDrawer(), - body: SafeArea( - child: RefreshIndicator( - onRefresh: () async { - if (nss.connectionUpdateStatus.value) { - return; - } - await manager.updateAllContacts(); - }, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - if (profileButton != null) ...[ - SizedBox(width: 70.0, child: profileButton), - const HorizontalPadding(), - ], - Expanded( - child: TextField( - onChanged: (value) { - setState(() { - filterText = value.toLowerCase(); - }); - }, - decoration: InputDecoration( - labelText: 'Filter By Name', - alignLabelWithHint: true, - border: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context).backgroundColor, - ), - borderRadius: BorderRadius.circular(5.0), - ), - ), - ), - ), - const HorizontalPadding(), - StatusAndRefreshButton( - valueListenable: nss.connectionUpdateStatus, - refreshFunction: () async => - await manager.updateAllContacts(), - ) - ], + + return SafeArea( + child: Scaffold( + appBar: AppBar( + leading: buildCurrentProfileButton(context), + title: TextField( + onChanged: (value) { + setState(() { + filterText = value.toLowerCase(); + }); + }, + decoration: InputDecoration( + labelText: 'Filter By Name', + alignLabelWithHint: true, + border: OutlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context).backgroundColor, ), + borderRadius: BorderRadius.circular(5.0), ), - const VerticalPadding(), - Expanded( - child: body, - ), - ], + ), ), ), - ), - bottomNavigationBar: AppBottomNavBar( - currentButton: NavBarButtons.contacts, + drawer: StandardAppDrawer(), + body: SafeArea( + child: RefreshIndicator( + onRefresh: () async { + if (nss.connectionUpdateStatus.value) { + return; + } + manager.updateAllContacts(); + return; + }, + child: Column( + children: [ + ValueListenableBuilder( + valueListenable: nss.connectionUpdateStatus, + builder: (context2, executing, _) { + if (executing) { + return const LinearProgressIndicator(); + } + + return const SizedBox(); + }), + Expanded(child: body), + ], + ), + ), + ), + bottomNavigationBar: AppBottomNavBar( + currentButton: NavBarButtons.contacts, + ), ), ); }