123 lines
4.4 KiB
Dart
123 lines
4.4 KiB
Dart
library home_view;
|
||
|
||
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 {
|
||
const Choice({this.title, this.icon});
|
||
|
||
final String title;
|
||
final IconData icon;
|
||
}
|
||
|
||
const List<Choice> choices = const <Choice>[
|
||
const Choice(title: 'Обновить номенклатуру', icon: Icons.directions_car),
|
||
const Choice(title: 'Помощь', icon: Icons.directions_car),
|
||
const Choice(title: 'О Программе', icon: Icons.directions_car),
|
||
const Choice(title: 'Язык', icon: Icons.directions_car),
|
||
const Choice(title: 'Выйти', icon: Icons.directions_bike)
|
||
];
|
||
|
||
class HomeView extends StatelessWidget {
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return ViewModelBuilder<HomeViewModel>.reactive(
|
||
viewModelBuilder: () => HomeViewModel(
|
||
authenticationService: Provider.of(context),
|
||
navigationService: Provider.of(context)),
|
||
onModelReady: (viewModel) {
|
||
viewModel.initialize();
|
||
viewModel.pageController =
|
||
new PageController(initialPage: viewModel.tabIndex);
|
||
},
|
||
builder: (context, viewModel, child) {
|
||
return Scaffold(
|
||
appBar: AppBar(
|
||
title: Center(
|
||
child: Container(
|
||
width: 100,
|
||
child: Image(
|
||
image: AssetImage('assets/images/logo.png'),
|
||
fit: BoxFit.fitHeight,
|
||
),
|
||
)),
|
||
actions: <Widget>[
|
||
PopupMenuButton<Choice>(
|
||
icon: Icon(
|
||
Icons.more_vert,
|
||
color: menuColor,
|
||
),
|
||
onSelected: (s) {},
|
||
itemBuilder: (BuildContext context) {
|
||
return choices.map((Choice choice) {
|
||
return PopupMenuItem<Choice>(
|
||
value: choice,
|
||
child: Text(choice.title),
|
||
);
|
||
}).toList();
|
||
},
|
||
)
|
||
],
|
||
backgroundColor: fillColor,
|
||
),
|
||
body: PageView(
|
||
onPageChanged: (index) {
|
||
viewModel.tabIndex = index;
|
||
},
|
||
controller: viewModel.pageController,
|
||
children: <Widget>[
|
||
KassaTab(viewModel, 0),
|
||
CalculatorTab(viewModel, 1),
|
||
AdditionalTab(viewModel, 2)
|
||
],
|
||
),
|
||
bottomNavigationBar: BottomNavigationBar(
|
||
currentIndex: viewModel.tabIndex,
|
||
backgroundColor: menuColor,
|
||
type: BottomNavigationBarType.shifting,
|
||
items: [
|
||
BottomNavigationBarItem(
|
||
backgroundColor: menuColor,
|
||
icon: Icon(MdiIcons.cashRegister, color: Colors.white),
|
||
title: new Text(
|
||
'Касса',
|
||
style: TextStyle(color: Colors.white),
|
||
)),
|
||
BottomNavigationBarItem(
|
||
icon: Icon(MdiIcons.calculator, color: Colors.white),
|
||
title: new Text(
|
||
'Калькулятор',
|
||
style: TextStyle(color: Colors.white),
|
||
)),
|
||
BottomNavigationBarItem(
|
||
icon: Icon(MdiIcons.tune, color: Colors.white),
|
||
title: new Text(
|
||
'Опции',
|
||
style: TextStyle(color: Colors.white),
|
||
)),
|
||
],
|
||
onTap: (index) {
|
||
viewModel.pageController.animateToPage(
|
||
index,
|
||
duration: const Duration(milliseconds: 300),
|
||
curve: Curves.easeIn,
|
||
);
|
||
},
|
||
),
|
||
);
|
||
});
|
||
}
|
||
}
|