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