Fix: some design fixes

This commit is contained in:
2024-06-12 02:03:20 +03:00
parent c0c3ef2ca0
commit 27da063c34
3 changed files with 59 additions and 43 deletions

View File

@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application <application
android:label="Example Gym App" android:label="Example Gym App"
android:name="${applicationName}" android:name="${applicationName}"
@@ -31,7 +32,6 @@
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
</application> </application>
<uses-permission android:name="android.permission.INTERNET" />
<!-- Required to query activities that can process text, see: <!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and https://developer.android.com/training/package-visibility?hl=en and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT. https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

View File

@@ -15,10 +15,10 @@ class ProductCard extends StatelessWidget {
}); });
double getCardHeight({required BuildContext context}) { double getCardHeight({required BuildContext context}) {
if (MediaQuery.of(context).size.width > 600) { if (MediaQuery.of(context).size.width > 400) {
return 200; return 300;
} }
return 100; return 160;
} }
@override @override
@@ -27,7 +27,9 @@ class ProductCard extends StatelessWidget {
onTap: onTap, onTap: onTap,
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints( constraints: BoxConstraints(
minHeight: 80, maxHeight: getCardHeight(context: context)), minHeight: 160,
maxHeight: getCardHeight(context: context),
),
child: Card( child: Card(
elevation: 3, elevation: 3,
color: Theme.of(context).scaffoldBackgroundColor, color: Theme.of(context).scaffoldBackgroundColor,
@@ -42,7 +44,8 @@ class ProductCard extends StatelessWidget {
const SizedBox(height: 16), const SizedBox(height: 16),
Text( Text(
name, name,
style: Theme.of(context).textTheme.titleLarge, style: Theme.of(context).textTheme.titleMedium,
maxLines: 2,
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Text( Text(

View File

@@ -154,10 +154,10 @@ class _MainPageState extends State<MainPage> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Поиск', hintText: 'Поиск',
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(50),
), ),
suffixIcon: Padding( suffixIcon: Padding(
padding: const EdgeInsets.only(right: 8), padding: const EdgeInsets.only(right: 5),
child: ElevatedButton( child: ElevatedButton(
onPressed: _onSearch, onPressed: _onSearch,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
@@ -213,38 +213,41 @@ class _MainPageState extends State<MainPage> {
], ],
), ),
), ),
SizedBox( Align(
height: 60, alignment: Alignment.centerLeft,
child: ListView.builder( child: SizedBox(
scrollDirection: Axis.horizontal, height: 60,
shrinkWrap: true, child: ListView.builder(
itemCount: categories.length, scrollDirection: Axis.horizontal,
itemBuilder: (context, index) { shrinkWrap: true,
final category = categories[index]; itemCount: categories.length,
return GestureDetector( itemBuilder: (context, index) {
onTap: () { final category = categories[index];
setState(() { return GestureDetector(
selectedCategory = onTap: () {
selectedCategory == category ? null : category; setState(() {
}); selectedCategory =
_onSearch(); selectedCategory == category ? null : category;
}, });
child: Padding( _onSearch();
padding: const EdgeInsets.symmetric( },
horizontal: 10, vertical: 10), child: Padding(
child: Chip( padding: const EdgeInsets.symmetric(
label: Text(category.name), horizontal: 10, vertical: 10),
backgroundColor: selectedCategory == category child: Chip(
? Theme.of(context).primaryColor label: Text(category.name),
: Colors.white, backgroundColor: selectedCategory == category
labelStyle: TextStyle( ? Theme.of(context).primaryColor
color: selectedCategory == category : Colors.white,
? Colors.white labelStyle: TextStyle(
: Colors.black), color: selectedCategory == category
? Colors.white
: Colors.black),
),
), ),
), );
); }),
}), ),
), ),
Expanded( Expanded(
child: LazyLoadScrollView( child: LazyLoadScrollView(
@@ -271,7 +274,9 @@ class _MainPageState extends State<MainPage> {
200) 200)
.toInt(), .toInt(),
8), 8),
childAspectRatio: 1.0), childAspectRatio: 0.8,
mainAxisSpacing: 10.0,
crossAxisSpacing: 40.0),
itemCount: itemViewCount, itemCount: itemViewCount,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final product = filteredData[index]; final product = filteredData[index];
@@ -280,7 +285,7 @@ class _MainPageState extends State<MainPage> {
image: image:
Image.network(product.images[0].url) Image.network(product.images[0].url)
.image, .image,
width: 50, width: 120,
), ),
name: shortString(product.title), name: shortString(product.title),
price: product.price.toStringAsFixed(2), price: product.price.toStringAsFixed(2),
@@ -310,9 +315,17 @@ class _MainPageState extends State<MainPage> {
Radius.circular(50)), Radius.circular(50)),
), ),
foregroundColor: Colors.white, foregroundColor: Colors.white,
fixedSize: const Size(180, 40),
), ),
child: const Text('Загрузить ещё'), child: const Row(
) mainAxisSize: MainAxisSize.min,
children: [
Text('Загрузить ещё'),
Spacer(),
Icon(Icons.arrow_downward),
Spacer()
],
))
: const CircularProgressIndicator() : const CircularProgressIndicator()
: const Text( : const Text(
'Конец списка', 'Конец списка',