Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

feat: search screen #3

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions lib/utils/item_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'package:flutter/material.dart';

class Item extends StatelessWidget {
final String child;

const Item({super.key, required this.child});

@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(16.0),
height: 90,
width: 90,
decoration: const BoxDecoration(
color: Color(0xFFF2F2F2),
borderRadius: BorderRadiusDirectional.all(
Radius.circular(4),
),
),
child: Center(
child: Text(
child,
style: const TextStyle(
fontSize: 14.0,
color: Color(0xFF4B64F2),
),
),
),
);
}
}

class ItemList extends StatefulWidget {
final List items;
const ItemList({super.key, required this.items});

@override
State<ItemList> createState() => _ItemListState();
}

class _ItemListState extends State<ItemList> {
@override
Widget build(BuildContext context) {
return Expanded(
child: ListView.builder(
itemCount: widget.items.length,
itemBuilder: (context, index) {
return Item(child: widget.items[index]);
},
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.all(8),
),
);
}
}
103 changes: 103 additions & 0 deletions lib/views/search_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import 'package:flutter/material.dart';

import '../utils/item_list.dart';

class SearchScreen extends StatelessWidget {
SearchScreen({super.key});

final List _genders = [
'Male',
'Unisex',
'Female',
];

final List _brands = [
'Gucci',
'Nike',
'Adidas',
'Puma',
'Ralph Lauren',
'Tommy Hilfiger',
];

final List _styles = [
'Sports',
'Elegant',
'Casual',
'Oversize',
'Fashion',
'Vintage',
];

final List _types = [
'T-shirts',
'Shirts',
'Suits',
'Jeans',
'Joggers',
'Shorts',
];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
'Fitster',
),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.all(16.0),
child: SearchBar(
leading: Icon(
Icons.search,
),
hintText: 'Search...',
),
),
ItemList(items: _genders),
const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Text(
'Brands',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF4B64F2),
),
),
),
ItemList(items: _brands),
const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Text(
'Styles',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF4B64F2),
),
),
),
ItemList(items: _styles),
const Padding(
padding: EdgeInsets.only(left: 16.0),
child: Text(
'Types',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF4B64F2),
),
),
),
ItemList(items: _types),
],
),
);
}
}