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

Commit

Permalink
feat: added main app navigation (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalbitresb12 committed Jun 27, 2023
2 parents 7fba39e + c11af5f commit c6675a2
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 99 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
16 changes: 11 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'views/pose_detector_view.dart';
import 'views/home_page.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -10,18 +11,23 @@ void main() {
class FitsterApp extends StatelessWidget {
const FitsterApp({super.key});

static const title = 'Fitster Demo';

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: title,
title: 'Fitster',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
appBarTheme: const AppBarTheme(
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.blue,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.dark,
),
),
),
home: const PoseDetectorView(title: title),
home: const HomePage(),
);
}
}
50 changes: 31 additions & 19 deletions lib/utils/item_list.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import 'package:flutter/material.dart';

class Item extends StatelessWidget {
import '../views/item_view.dart';

class _Item extends StatelessWidget {
final String child;

const Item({super.key, required this.child});
const _Item({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),
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ItemView(),
),
);
},
child: 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),
child: Center(
child: Text(
child,
style: const TextStyle(
fontSize: 14.0,
color: Color(0xFF4B64F2),
),
),
),
),
Expand All @@ -31,7 +43,7 @@ class Item extends StatelessWidget {
}

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

@override
Expand All @@ -45,7 +57,7 @@ class _ItemListState extends State<ItemList> {
child: ListView.builder(
itemCount: widget.items.length,
itemBuilder: (context, index) {
return Item(child: widget.items[index]);
return _Item(child: widget.items[index]);
},
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.all(8),
Expand Down
14 changes: 7 additions & 7 deletions lib/views/camera_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ enum CameraViewStatus {
}

class CameraView extends StatefulWidget {
final String title;
final Function(InputImage inputImage) onImage;
final CustomPaint? customPaint;
final CameraLensDirection initialDirection;

const CameraView({
super.key,
required this.title,
required this.onImage,
this.customPaint,
this.initialDirection = CameraLensDirection.back,
Expand Down Expand Up @@ -61,7 +59,7 @@ class _CameraViewState extends State<CameraView> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
title: const Text('Fitster'),
actions: [
if (_status.isLive)
Padding(
Expand Down Expand Up @@ -196,13 +194,15 @@ class _CameraViewState extends State<CameraView> {
Future<void> _stopLiveFeed() async {
if (!_status.isLive) return;

setState(() {
_status = CameraViewStatus.stopped;
});

await _controller?.stopImageStream();
await _controller?.dispose();
_controller = null;

if (mounted) {
setState(() {
_status = CameraViewStatus.stopped;
});
}
}

Future<void> _processImageStream(CameraImage image) async {
Expand Down
45 changes: 30 additions & 15 deletions lib/views/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
import 'package:flutter/material.dart';

import 'search_view.dart';

class HomePage extends StatelessWidget {
const HomePage({super.key});

@override
Widget build(BuildContext context) {
return Column(
children: [
const Image(image: AssetImage('logo.png')),
const SizedBox(height: 32),
FilledButton(
onPressed: () {},
style: const ButtonStyle(
backgroundColor:
MaterialStatePropertyAll<Color>(Color(0xFF4B64F2)),
fixedSize: MaterialStatePropertyAll<Size>(Size(128, 48))),
child: const Text(
'Start',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.normal),
),
return SafeArea(
child: Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Image(image: AssetImage('assets/logo.png')),
const SizedBox(height: 32),
FilledButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SearchView(),
),
);
},
style: const ButtonStyle(
backgroundColor:
MaterialStatePropertyAll<Color>(Color(0xFF4B64F2)),
fixedSize: MaterialStatePropertyAll<Size>(Size(128, 48))),
child: const Text(
'Start',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.normal),
),
),
],
),
],
),
);
}
}
11 changes: 10 additions & 1 deletion lib/views/item_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';

import 'pose_detector_view.dart';

class ItemView extends StatefulWidget {
const ItemView({super.key});

Expand Down Expand Up @@ -98,7 +100,14 @@ class _ItemViewState extends State<ItemView> {
.toList(),
),
ElevatedButton(
onPressed: () {},
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const PoseDetectorView(),
),
);
},
child: const Text('Try on', style: TextStyle(fontSize: 14)),
),
],
Expand Down
8 changes: 1 addition & 7 deletions lib/views/pose_detector_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import '../painters/pose_painter.dart';
import 'camera_view.dart';

class PoseDetectorView extends StatefulWidget {
final String title;

const PoseDetectorView({
super.key,
required this.title,
});
const PoseDetectorView({super.key});

@override
State<PoseDetectorView> createState() => _PoseDetectorViewState();
Expand Down Expand Up @@ -39,7 +34,6 @@ class _PoseDetectorViewState extends State<PoseDetectorView> {
@override
Widget build(BuildContext context) {
return CameraView(
title: widget.title,
onImage: processImage,
customPaint: _customPaint,
);
Expand Down
79 changes: 35 additions & 44 deletions lib/views/search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import 'package:flutter/material.dart';

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

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

final List _genders = [
static const List<String> genders = [
'Male',
'Unisex',
'Female',
];

final List _brands = [
static const List<String> brands = [
'Gucci',
'Nike',
'Adidas',
Expand All @@ -20,7 +20,7 @@ class SearchScreen extends StatelessWidget {
'Tommy Hilfiger',
];

final List _styles = [
static const List<String> styles = [
'Sports',
'Elegant',
'Casual',
Expand All @@ -29,7 +29,7 @@ class SearchScreen extends StatelessWidget {
'Vintage',
];

final List _types = [
static const List<String> types = [
'T-shirts',
'Shirts',
'Suits',
Expand All @@ -46,7 +46,7 @@ class SearchScreen extends StatelessWidget {
'Fitster',
),
),
body: Column(
body: const Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand All @@ -59,45 +59,36 @@ class SearchScreen extends StatelessWidget {
// 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),
ItemList(items: genders),
_SectionTitle(child: Text('Brands')),
ItemList(items: brands),
_SectionTitle(child: Text('Styles')),
ItemList(items: styles),
_SectionTitle(child: Text('Types')),
ItemList(items: types),
],
),
);
}
}

class _SectionTitle extends StatelessWidget {
final Widget child;

const _SectionTitle({required this.child});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 16.0),
child: DefaultTextStyle(
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF4B64F2),
),
child: child,
),
);
}
}

0 comments on commit c6675a2

Please sign in to comment.