From 51a805e0cf2d82795e738691dba9b3569bb9b555 Mon Sep 17 00:00:00 2001 From: Felipe Erias Date: Wed, 1 Dec 2021 13:52:06 +0900 Subject: Add LayoutSizeHelper --- lib/page_home.dart | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'lib/page_home.dart') diff --git a/lib/page_home.dart b/lib/page_home.dart index 1fbda1f..7b4bc79 100644 --- a/lib/page_home.dart +++ b/lib/page_home.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_homescreen/layout_size_helper.dart'; class HomePage extends StatelessWidget { final Function(int index) onSetNavigationIndex; @@ -8,35 +9,34 @@ class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { - final double spacing = MediaQuery.of(context).size.width / 32; - final double runSpacing = spacing / 2; + var themeHelper = LayoutSizeHelper(context); return Container( color: Colors.lightBlue.shade50, constraints: BoxConstraints.expand(), alignment: Alignment.center, child: Wrap( - spacing: spacing, - runSpacing: runSpacing, - children: [ - createItem(context, Icons.drive_eta, 1), - createItem(context, Icons.thermostat, 2), - createItem(context, Icons.music_note, 3) - ], - )); + spacing: themeHelper.largePadding, + runSpacing: themeHelper.largePadding, + children: [ + createItem(themeHelper, Icons.drive_eta, 1), + createItem(themeHelper, Icons.thermostat, 2), + createItem(themeHelper, Icons.music_note, 3) + ], + )); } - Widget createItem(BuildContext context, IconData icon, int tabPosition) { - final double size = MediaQuery.of(context).size.width / 6; - final double padding = size / 4; - final double border = padding / 4; + Widget createItem( + LayoutSizeHelper themeHelper, IconData icon, int tabPosition) { return Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), child: OutlinedButton( style: OutlinedButton.styleFrom( shape: CircleBorder(), - padding: EdgeInsets.all(padding), + padding: EdgeInsets.all(themeHelper.largePadding), primary: Colors.lightBlue.shade400, - side: BorderSide(width: border, color: Colors.lightBlue.shade400) + side: BorderSide( + width: themeHelper.defaultBorder, + color: Colors.lightBlue.shade400), ), onPressed: () { onSetNavigationIndex(tabPosition); @@ -44,7 +44,7 @@ class HomePage extends StatelessWidget { child: Icon( icon, color: Colors.lightBlue.shade800, - size: size / 2, + size: themeHelper.largeIconSize, ), ), ); -- cgit 1.2.3-korg