Skip to content

Commit

Permalink
refactor: apply sliver to home screen
Browse files Browse the repository at this point in the history
  • Loading branch information
deandreamatias committed Oct 1, 2023
1 parent fa07979 commit 581f0ad
Showing 1 changed file with 46 additions and 37 deletions.
83 changes: 46 additions & 37 deletions lib/ui/widgets/screens/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:dog_gromming_website/ui/styles/sizes.dart';
import 'package:dog_gromming_website/ui/styles/spacing.dart';
import 'package:dog_gromming_website/ui/widgets/components/box_spacer.dart';
import 'package:dog_gromming_website/ui/widgets/components/footer.dart';
import 'package:dog_gromming_website/ui/widgets/components/sliver_footer.dart';
import 'package:dog_gromming_website/ui/widgets/screens/home/components/welcome_board.dart';
import 'package:dog_gromming_website/ui/widgets/screens/home/components/welcome_body.dart';
import 'package:dog_gromming_website/ui/widgets/screens/home/components/when_card.dart';
Expand All @@ -14,45 +15,53 @@ class HomeScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final double maxWidth = constraints.maxWidth;

return ScrollConfiguration(
behavior: const ScrollBehavior().copyWith(overscroll: false),
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: Column(
children: [
maxWidth > Sizes.m.width
? Padding(
padding: Insets.a16,
child: BigWelcomeBoard(
maxWidth: maxWidth - Insets.a16.horizontal,
child: const BigWelcomeBody(),
),
)
: Padding(
padding: Insets.a16,
child: SmallWelcomeBoard(
maxWidth: maxWidth - Insets.a16.horizontal,
child: const SmallWelcomeBody(),
),
),
BoxSpacer.v8(),
Padding(
padding: Insets.a16,
child: _WhereWhenSection(maxWidth: maxWidth),
),
BoxSpacer.v8(),
if (Sizes.s.width < maxWidth) const Footer(),
],
),
return CustomScrollView(
physics: const BouncingScrollPhysics(),
shrinkWrap: true,
slivers: <Widget>[
SliverToBoxAdapter(child: BoxSpacer.v16()),
SliverPadding(
padding: Insets.a16,
sliver: SliverLayoutBuilder(
builder: (context, constraints) {
return constraints.crossAxisExtent > Sizes.m.width
? SliverToBoxAdapter(
child: BigWelcomeBoard(
maxWidth: constraints.crossAxisExtent,
child: const BigWelcomeBody(),
),
)
: SliverToBoxAdapter(
child: SmallWelcomeBoard(
maxWidth: constraints.crossAxisExtent,
child: const SmallWelcomeBody(),
),
);
},
),
),
SliverToBoxAdapter(child: BoxSpacer.v8()),
SliverPadding(
padding: Insets.h16,
sliver: SliverLayoutBuilder(
builder: (context, constraints) => SliverToBoxAdapter(
child: _WhereWhenSection(maxWidth: constraints.crossAxisExtent),
),
),
);
},
),
SliverToBoxAdapter(child: BoxSpacer.v8()),
SliverLayoutBuilder(
builder: (context, constraints) =>
Sizes.s.width < constraints.crossAxisExtent
? const SliverFooter(
child: Align(
alignment: Alignment.bottomCenter,
child: Footer(),
),
)
: const SliverToBoxAdapter(child: SizedBox()),
),
],
);
}
}
Expand Down

0 comments on commit 581f0ad

Please sign in to comment.