Improvements clients view

This commit is contained in:
Juan Gilsanz Polo 2023-05-04 01:59:50 +02:00
parent dafff9b242
commit 769238cff9
3 changed files with 206 additions and 157 deletions

View file

@ -131,7 +131,7 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
); );
} }
Widget tabBarView() { Widget tabBarView(bool sliver) {
return TabBarView( return TabBarView(
controller: tabController, controller: tabController,
children: [ children: [
@ -149,6 +149,7 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
) )
)), )),
splitView: false, splitView: false,
sliver: sliver,
), ),
AddedList( AddedList(
scrollController: scrollController, scrollController: scrollController,
@ -169,7 +170,6 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
); );
} }
if (!(Platform.isAndroid || Platform.isIOS)) {
if (width > 900) { if (width > 900) {
return SplitView.material( return SplitView.material(
hideDivider: true, hideDivider: true,
@ -195,6 +195,7 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
); );
} }
else { else {
if (!(Platform.isAndroid || Platform.isIOS)) {
return DefaultTabController( return DefaultTabController(
length: 2, length: 2,
child: Scaffold( child: Scaffold(
@ -217,11 +218,10 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
], ],
bottom: tabBar() bottom: tabBar()
), ),
body: tabBarView(), body: tabBarView(false),
), ),
); );
} }
}
else { else {
return DefaultTabController( return DefaultTabController(
length: 2, length: 2,
@ -295,9 +295,10 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
) )
]; ];
}), }),
body: tabBarView() body: tabBarView(true)
) )
); );
} }
} }
}
} }

View file

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_split_view/flutter_split_view.dart'; import 'package:flutter_split_view/flutter_split_view.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -84,7 +86,7 @@ class _ClientsDesktopViewState extends State<ClientsDesktopView> with TickerPro
); );
} }
Widget tabBarView() { Widget tabBarView(bool sliver) {
return TabBarView( return TabBarView(
controller: tabController, controller: tabController,
children: [ children: [
@ -107,7 +109,8 @@ class _ClientsDesktopViewState extends State<ClientsDesktopView> with TickerPro
); );
}), }),
selectedClient: selectedActiveClient, selectedClient: selectedActiveClient,
splitView: true splitView: true,
sliver: sliver,
), ),
AddedList( AddedList(
scrollController: scrollController, scrollController: scrollController,
@ -134,12 +137,9 @@ class _ClientsDesktopViewState extends State<ClientsDesktopView> with TickerPro
); );
} }
return DefaultTabController( Widget title() {
length: 2, if (searchMode == true) {
child: Scaffold( return Row(
appBar: AppBar(
title: searchMode == true
? Row(
children: [ children: [
IconButton( IconButton(
onPressed: () { onPressed: () {
@ -180,8 +180,19 @@ class _ClientsDesktopViewState extends State<ClientsDesktopView> with TickerPro
), ),
) )
], ],
) );
: Text(AppLocalizations.of(context)!.clients), }
else {
return Text(AppLocalizations.of(context)!.clients);
}
}
if (!(Platform.isAndroid || Platform.isIOS)) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: title(),
centerTitle: false, centerTitle: false,
actions: [ actions: [
if (serversProvider.clients.loadStatus == LoadStatus.loaded && searchMode == false) ...[ if (serversProvider.clients.loadStatus == LoadStatus.loaded && searchMode == false) ...[
@ -195,8 +206,43 @@ class _ClientsDesktopViewState extends State<ClientsDesktopView> with TickerPro
], ],
bottom: tabBar() bottom: tabBar()
), ),
body: tabBarView(), body: tabBarView(false),
), ),
); );
} }
else {
return DefaultTabController(
length: 2,
child: NestedScrollView(
controller: scrollController,
headerSliverBuilder: ((context, innerBoxIsScrolled) {
return [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar(
title: title(),
pinned: true,
floating: true,
centerTitle: false,
forceElevated: innerBoxIsScrolled,
actions: [
if (serversProvider.clients.loadStatus == LoadStatus.loaded && searchMode == false) ...[
IconButton(
onPressed: () => setState(() => searchMode = true),
icon: const Icon(Icons.search),
tooltip: AppLocalizations.of(context)!.searchClients,
),
const SizedBox(width: 10),
]
],
bottom: tabBar()
),
)
];
}),
body: tabBarView(true)
)
);
}
}
} }

View file

@ -18,6 +18,7 @@ class ClientsList extends StatelessWidget {
final void Function(AutoClient) onClientSelected; final void Function(AutoClient) onClientSelected;
final AutoClient? selectedClient; final AutoClient? selectedClient;
final bool splitView; final bool splitView;
final bool sliver;
const ClientsList({ const ClientsList({
Key? key, Key? key,
@ -27,7 +28,8 @@ class ClientsList extends StatelessWidget {
required this.fetchClients, required this.fetchClients,
required this.onClientSelected, required this.onClientSelected,
this.selectedClient, this.selectedClient,
required this.splitView required this.splitView,
required this.sliver
}) : super(key: key); }) : super(key: key);
@override @override
@ -36,7 +38,7 @@ class ClientsList extends StatelessWidget {
listPadding: splitView == true listPadding: splitView == true
? const EdgeInsets.only(top: 8) ? const EdgeInsets.only(top: 8)
: null, : null,
noSliver: !(Platform.isAndroid || Platform.isIOS), noSliver: !sliver,
loadingGenerator: () => SizedBox( loadingGenerator: () => SizedBox(
width: double.maxFinite, width: double.maxFinite,
height: MediaQuery.of(context).size.height-171, height: MediaQuery.of(context).size.height-171,