create new start file
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_action.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih_app.dart';
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_body.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih_app_action.dart';
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_header.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih_app_tools.dart';
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_layout_builder.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_packages/calculator/app_tools/simple_calc.dart';
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_objects/arguments.dart';
|
import 'package:Mzansi_Innovation_Hub/mih_packages/calculator/app_tools/tip_calc.dart';
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_packages/calculator/simple_calc.dart';
|
|
||||||
import 'package:Mzansi_Innovation_Hub/mih_packages/calculator/tip_calc.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_swipe_detector/flutter_swipe_detector.dart';
|
|
||||||
|
|
||||||
class MIHCalculator extends StatefulWidget {
|
class MIHCalculator extends StatefulWidget {
|
||||||
final bool personalSelected;
|
final bool personalSelected;
|
||||||
@@ -22,177 +19,55 @@ class MIHCalculator extends StatefulWidget {
|
|||||||
class _MIHCalculatorState extends State<MIHCalculator> {
|
class _MIHCalculatorState extends State<MIHCalculator> {
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
MIHAction getActionButton() {
|
@override
|
||||||
return MIHAction(
|
Widget build(BuildContext context) {
|
||||||
|
return MihApp(
|
||||||
|
appActionButton: getAction(),
|
||||||
|
appTools: getTools(),
|
||||||
|
appBody: getToolBody(),
|
||||||
|
selectedbodyIndex: _selectedIndex,
|
||||||
|
onIndexChange: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
_selectedIndex = newValue;
|
||||||
|
});
|
||||||
|
print("Index: $_selectedIndex");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihAppAction getAction() {
|
||||||
|
return MihAppAction(
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
iconSize: 35,
|
iconSize: 35,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).popAndPushNamed(
|
|
||||||
'/',
|
|
||||||
arguments: AuthArguments(widget.personalSelected, false),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MIHHeader getHeader() {
|
MihAppTools getTools() {
|
||||||
return const MIHHeader(
|
Map<Widget, void Function()?> temp = {};
|
||||||
headerAlignment: MainAxisAlignment.center,
|
temp[const Icon(Icons.calculate)] = () {
|
||||||
headerItems: [
|
|
||||||
Text(
|
|
||||||
"",
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
MIHHeader getSecAction() {
|
|
||||||
return MIHHeader(
|
|
||||||
headerAlignment: MainAxisAlignment.end,
|
|
||||||
headerItems: [
|
|
||||||
//============ Simple Calc ================
|
|
||||||
Visibility(
|
|
||||||
visible: _selectedIndex != 0,
|
|
||||||
child: IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedIndex = 0;
|
_selectedIndex = 0;
|
||||||
});
|
});
|
||||||
},
|
};
|
||||||
icon: const Icon(
|
temp[const Icon(Icons.money)] = () {
|
||||||
Icons.calculate,
|
|
||||||
size: 35,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: _selectedIndex == 0,
|
|
||||||
child: IconButton.filled(
|
|
||||||
iconSize: 35,
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = 0;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.calculate,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
//============ Tip Calc ================
|
|
||||||
Visibility(
|
|
||||||
visible: _selectedIndex != 1,
|
|
||||||
child: IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedIndex = 1;
|
_selectedIndex = 1;
|
||||||
});
|
});
|
||||||
},
|
};
|
||||||
icon: const Icon(
|
return MihAppTools(
|
||||||
Icons.money,
|
tools: temp,
|
||||||
size: 35,
|
selcetedIndex: _selectedIndex,
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: _selectedIndex == 1,
|
|
||||||
child: IconButton.filled(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = 1;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.money,
|
|
||||||
size: 35,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// //============ Patient Files ================
|
|
||||||
// Visibility(
|
|
||||||
// visible: _selectedIndex != 2,
|
|
||||||
// child: IconButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// setState(() {
|
|
||||||
// _selectedIndex = 2;
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// icon: const Icon(
|
|
||||||
// Icons.file_present,
|
|
||||||
// size: 35,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Visibility(
|
|
||||||
// visible: _selectedIndex == 2,
|
|
||||||
// child: IconButton.filled(
|
|
||||||
// onPressed: () {
|
|
||||||
// setState(() {
|
|
||||||
// _selectedIndex = 2;
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// icon: const Icon(
|
|
||||||
// Icons.file_present,
|
|
||||||
// size: 35,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MIHBody getBody() {
|
List<Widget> getToolBody() {
|
||||||
return MIHBody(
|
List<Widget> toolBodies = [
|
||||||
borderOn: true,
|
const SimpleCalc(),
|
||||||
bodyItems: [showSelection(_selectedIndex)],
|
const TipCalc(),
|
||||||
);
|
];
|
||||||
}
|
return toolBodies;
|
||||||
|
|
||||||
Widget showSelection(int index) {
|
|
||||||
if (index == 0) {
|
|
||||||
return const SimpleCalc();
|
|
||||||
} else if (index == 1) {
|
|
||||||
return const TipCalc();
|
|
||||||
} else {
|
|
||||||
return const Placeholder();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SwipeDetector(
|
|
||||||
onSwipeLeft: (offset) {
|
|
||||||
if (_selectedIndex < 1) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex += 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//print("swipe left");
|
|
||||||
},
|
|
||||||
onSwipeRight: (offset) {
|
|
||||||
if (_selectedIndex > 0) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex -= 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//print("swipe right");
|
|
||||||
},
|
|
||||||
child: MIHLayoutBuilder(
|
|
||||||
actionButton: getActionButton(),
|
|
||||||
header: getHeader(),
|
|
||||||
secondaryActionButton: getSecAction(),
|
|
||||||
body: getBody(),
|
|
||||||
actionDrawer: null,
|
|
||||||
secondaryActionDrawer: null,
|
|
||||||
bottomNavBar: null,
|
|
||||||
pullDownToRefresh: false,
|
|
||||||
onPullDown: () async {},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user