forked from yaso_meth/mih-project
add ai package
This commit is contained in:
78
Frontend/lib/mih_packages/mzansi_ai/mzansi_ai.dart
Normal file
78
Frontend/lib/mih_packages/mzansi_ai/mzansi_ai.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih_app.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:Mzansi_Innovation_Hub/mih_objects/app_user.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_objects/arguments.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_ai/ai_chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MzansiAi extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
const MzansiAi({
|
||||
super.key,
|
||||
required this.signedInUser,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MzansiAi> createState() => _MzansiAiState();
|
||||
}
|
||||
|
||||
class _MzansiAiState extends State<MzansiAi> {
|
||||
int _selcetedIndex = 0;
|
||||
|
||||
MihAppAction getAction() {
|
||||
return MihAppAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
'/',
|
||||
arguments: AuthArguments(true, false),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihAppTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.chat)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
};
|
||||
|
||||
return MihAppTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
AiChat(signedInUser: widget.signedInUser),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihApp(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
print("Index: $_selcetedIndex");
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user