Create new Mzansi Package Template
This commit is contained in:
82
Frontend/lib/mih_components/mih_package/mih_app.dart
Normal file
82
Frontend/lib/mih_components/mih_package/mih_app.dart
Normal file
@@ -0,0 +1,82 @@
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih-app_tool_body.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih_app_action.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih_app_tools.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_swipe_detector/flutter_swipe_detector.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MihApp extends StatefulWidget {
|
||||
final MihAppAction appActionButton;
|
||||
final MihAppTools appTools;
|
||||
final List<MihAppToolBody> appBody;
|
||||
int selectedbodyIndex;
|
||||
final onIndexChange;
|
||||
MihApp({
|
||||
super.key,
|
||||
required this.appActionButton,
|
||||
required this.appTools,
|
||||
required this.appBody,
|
||||
required this.selectedbodyIndex,
|
||||
required this.onIndexChange,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihApp> createState() => _MihAppState();
|
||||
}
|
||||
|
||||
class _MihAppState extends State<MihApp> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size screenSize = MediaQuery.of(context).size;
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Container(
|
||||
width: screenSize.width,
|
||||
height: screenSize.height,
|
||||
//color: Colors.black,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
widget.appActionButton,
|
||||
Flexible(child: widget.appTools),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: SwipeDetector(
|
||||
onSwipeLeft: (offset) {
|
||||
if (widget.selectedbodyIndex <
|
||||
widget.appTools.tools.length - 1) {
|
||||
setState(() {
|
||||
widget.selectedbodyIndex += 1;
|
||||
widget.onIndexChange(widget.selectedbodyIndex);
|
||||
});
|
||||
}
|
||||
// print("swipe left");
|
||||
},
|
||||
onSwipeRight: (offset) {
|
||||
if (widget.selectedbodyIndex > 0) {
|
||||
setState(() {
|
||||
widget.selectedbodyIndex -= 1;
|
||||
widget.onIndexChange(widget.selectedbodyIndex);
|
||||
});
|
||||
}
|
||||
// print("swipe right");
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: widget.appBody[widget.selectedbodyIndex],
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user