Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated icons in BottomNavigationBar #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions assets/icons/ic_basket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/ic_location.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/ic_orders.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/icons/ic_profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/ic_shop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions lib/presentation/home_route.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutterapp/resources/app_icons.dart';
import 'package:flutterapp/resources/app_messages.dart';
import 'package:flutterapp/presentation/basket_route.dart';
import 'package:flutterapp/presentation/location_route.dart';
import 'package:flutterapp/presentation/orders_route.dart';
import 'package:flutterapp/presentation/profile_route.dart';
import 'package:flutterapp/presentation/shop_route.dart';
import 'package:flutterapp/widgets/svg_icon.dart';

class HomeRoute extends StatefulWidget {
@override
Expand Down Expand Up @@ -81,23 +83,23 @@ class _BottomTabsView extends StatelessWidget {
selectedItemColor: Colors.teal[400],
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.location_on),
icon: SvgIcon(AppIcons.location),
title: Text(AppMessages.locationTitle),
),
BottomNavigationBarItem(
icon: Icon(Icons.shop),
icon: SvgIcon(AppIcons.shop),
title: Text(AppMessages.shopTitle),
),
BottomNavigationBarItem(
icon: Icon(Icons.note),
icon: SvgIcon(AppIcons.orders),
title: Text(AppMessages.ordersTitle),
),
BottomNavigationBarItem(
icon: Icon(Icons.shopping_cart),
icon: SvgIcon(AppIcons.basket),
title: Text(AppMessages.basketTitle),
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
icon: SvgIcon(AppIcons.profile),
title: Text(AppMessages.profileTitle),
),
],
Expand Down
9 changes: 9 additions & 0 deletions lib/resources/app_icons.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AppIcons {
static const String _iconsPath = "assets/icons/";

static const String basket = _iconsPath + "ic_basket.svg";
static const String location = _iconsPath + "ic_location.svg";
static const String orders = _iconsPath + "ic_orders.svg";
static const String shop = _iconsPath + "ic_shop.svg";
static const String profile = _iconsPath + "ic_profile.svg";
}
20 changes: 20 additions & 0 deletions lib/widgets/svg_icon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class SvgIcon extends StatelessWidget {
const SvgIcon(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add default parameters to this constructor, so it will be possible to control color and size not only with theme:

const SvgIcon(
this.iconPath,
this.iconColor = null,
this.iconWidth = null,
this.iconHeight = null
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or let's keep it as is, but rename to something like BottomBarIcon and use it only there?

this.iconPath
);

final String iconPath;

@override
Widget build(BuildContext context) {
return SvgPicture.asset(
iconPath,
color: IconTheme.of(context).color,
width: IconTheme.of(context).size,
height: IconTheme.of(context).size,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of 3 times call IconTheme.of(context) it would be nice to create local variable and retrieve properties from local object.
var iconThemeData = IconTheme.of(context);
And then in constructor - color = iconThemeData.color

);
}
}
29 changes: 29 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_svg:
dependency: "direct main"
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.4"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -102,6 +109,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
Expand Down Expand Up @@ -186,3 +214,4 @@ packages:
version: "3.6.1"
sdks:
dart: ">=2.6.0 <3.0.0"
flutter: ">=1.6.7 <2.0.0"
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
flutter_svg: ^0.17.4

dev_dependencies:
flutter_test:
Expand All @@ -43,6 +44,8 @@ flutter:
- assets/images/
- assets/images/2.0x/
- assets/images/3.0x/
- assets/icons/

fonts:
- family: SFProText
fonts:
Expand Down