Product View Component
parent
9fe2c71075
commit
9c9dc94f1b
|
|
@ -0,0 +1,9 @@
|
|||
class ProductDao {
|
||||
final String name;
|
||||
final double price;
|
||||
int count;
|
||||
|
||||
|
||||
ProductDao( {this.name, this.price, this.count});
|
||||
|
||||
}
|
||||
|
|
@ -4,14 +4,15 @@ import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
|||
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:aman_kassa_flutter/core/models/ProductDao.dart';
|
||||
import 'package:aman_kassa_flutter/widgets/components/ProductListItem.dart';
|
||||
import 'home_view_model.dart';
|
||||
|
||||
part './tabs/KassaTab.dart';
|
||||
|
||||
part './tabs/CalculatorTab.dart';
|
||||
|
||||
part './tabs/AdditionalTab.dart';
|
||||
|
||||
class Choice {
|
||||
|
|
@ -89,19 +90,19 @@ class HomeView extends StatelessWidget {
|
|||
items: [
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: menuColor,
|
||||
icon: Icon(Icons.add_shopping_cart, color: Colors.white),
|
||||
icon: Icon(MdiIcons.cashRegister, color: Colors.white),
|
||||
title: new Text(
|
||||
'Касса',
|
||||
style: TextStyle(color: Colors.white),
|
||||
)),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.cake, color: Colors.white),
|
||||
icon: Icon(MdiIcons.calculator, color: Colors.white),
|
||||
title: new Text(
|
||||
'Калькулятор',
|
||||
style: TextStyle(color: Colors.white),
|
||||
)),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.assignment, color: Colors.white),
|
||||
icon: Icon(MdiIcons.tune, color: Colors.white),
|
||||
title: new Text(
|
||||
'Опции',
|
||||
style: TextStyle(color: Colors.white),
|
||||
|
|
|
|||
|
|
@ -12,27 +12,27 @@ class HomeViewModel extends BaseViewModel {
|
|||
AuthenticationService _authenticationService;
|
||||
final DialogService _dialogService = locator<DialogService>();
|
||||
|
||||
User _currentUser ;
|
||||
User get currentUser => _currentUser;
|
||||
|
||||
HomeViewModel({
|
||||
@required AuthenticationService authenticationService,
|
||||
@required NavigatorService navigationService,
|
||||
}) :
|
||||
_authenticationService = authenticationService ,
|
||||
_navigationService = navigationService;
|
||||
}) : _authenticationService = authenticationService,
|
||||
_navigationService = navigationService;
|
||||
|
||||
User _currentUser;
|
||||
User get currentUser => _currentUser;
|
||||
|
||||
int _tabIndex = 0;
|
||||
int get tabIndex => this._tabIndex;
|
||||
set tabIndex(int index) {
|
||||
this._tabIndex = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
PageController get pageController => this._pageController;
|
||||
PageController _pageController;
|
||||
set pageController(PageController pageController) {
|
||||
this._pageController = pageController;
|
||||
}
|
||||
set tabIndex(int index) {
|
||||
this._tabIndex = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void initialize() {
|
||||
_currentUser = _authenticationService.currentUser;
|
||||
|
|
@ -40,9 +40,7 @@ class HomeViewModel extends BaseViewModel {
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
_pageController.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,39 @@
|
|||
part of home_view;
|
||||
|
||||
List<String> litems = ["1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4"];
|
||||
List<String> litems = [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4"
|
||||
];
|
||||
|
||||
class KassaTab extends StatelessWidget {
|
||||
final HomeViewModel viewModel;
|
||||
|
|
@ -8,13 +41,16 @@ class KassaTab extends StatelessWidget {
|
|||
|
||||
KassaTab(this.viewModel, this.index);
|
||||
|
||||
Widget buildBody(BuildContext ctxt, int index) {
|
||||
return new Text(litems[index]);
|
||||
Widget buildItem(BuildContext ctxt, int index) {
|
||||
return ProductListItem(
|
||||
item: new ProductDao(name: 'Наименование', count: 123, price: 2332.02),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: fillColor,
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Column(
|
||||
|
|
@ -53,11 +89,10 @@ class KassaTab extends StatelessWidget {
|
|||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: ListView.builder
|
||||
(
|
||||
child: ListView.builder(
|
||||
itemCount: litems.length,
|
||||
itemBuilder: (BuildContext ctxt, int index) => buildBody(ctxt, index)
|
||||
),
|
||||
itemBuilder: (BuildContext ctxt, int index) =>
|
||||
buildItem(ctxt, index)),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||
import 'package:aman_kassa_flutter/core/models/ProductDao.dart';
|
||||
|
||||
class ProductListItem extends StatelessWidget {
|
||||
|
||||
ProductDao item;
|
||||
|
||||
ProductListItem({
|
||||
this.item
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: whiteColor,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Text(item.name)
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: whiteColor,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Text('${item.price?.toString()} x ${item.count?.toString()}', textAlign: TextAlign.right)
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: whiteColor,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 4),
|
||||
child: Text(item.name)
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(child: Text(item.name)),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -137,6 +137,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.6"
|
||||
material_design_icons_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: material_design_icons_flutter
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.5345"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ dependencies:
|
|||
http: ^0.12.1
|
||||
google_fonts: ^1.1.0
|
||||
flutter_boom_menu: ^1.0.2
|
||||
material_design_icons_flutter: ^4.0.5345
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
|
|||
Loading…
Reference in New Issue