Saját belépés slide buttonnal.

This commit is contained in:
Vincze József 2024-06-03 12:05:27 +02:00
parent 6c69efd3ea
commit 695c8897a3
6 changed files with 221 additions and 66 deletions

View File

@ -408,7 +408,7 @@ class _workTimeDetailsState extends State<workTimeDetails> {
Widget _getrow(StartStop e) { Widget _getrow(StartStop e) {
final DateFormat formatter = DateFormat('HH:mm'); final DateFormat formatter = DateFormat('HH:mm');
var start = DateFormat("yyyy.MM.dd. HH:mm").parse(e.start.toString()); var start = DateFormat("yyyy.MM.dd. HH:mm").parse(e.start.toString());
DateTime stop; DateTime stop=DateTime(2024);
late Duration diff; late Duration diff;
if (e.stop != '-') { if (e.stop != '-') {
stop = DateFormat("yyyy.MM.dd. HH:mm").parse(e.stop.toString()); stop = DateFormat("yyyy.MM.dd. HH:mm").parse(e.stop.toString());

View File

@ -8,6 +8,7 @@ import 'package:mobile_portal_23/widgets/reportList.dart' as reportList_page;
import 'package:mobile_portal_23/widgets/reportNew.dart' as reportNew_page; import 'package:mobile_portal_23/widgets/reportNew.dart' as reportNew_page;
import 'package:mobile_portal_23/widgets/reportDetails.dart' as reportDetails_page; import 'package:mobile_portal_23/widgets/reportDetails.dart' as reportDetails_page;
import 'package:mobile_portal_23/report_selectWork.dart' as reportSelectWork_page; import 'package:mobile_portal_23/report_selectWork.dart' as reportSelectWork_page;
import 'package:mobile_portal_23/widgets/reportCreate.dart' as testRepCreate_page;
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
} }
@ -47,7 +48,7 @@ class MyApp extends StatelessWidget {
'/':(context)=>const main_page.MainPage(), '/':(context)=>const main_page.MainPage(),
'/wtdetails': (context) => const worktime_page.workTimeDetails(), '/wtdetails': (context) => const worktime_page.workTimeDetails(),
'/reportNav': (context)=> const dailyReportNav_page.reportNav(), '/reportNav': (context)=> const dailyReportNav_page.reportNav(),
//'/reportCreate': (context)=> testRepCreate_page.ReportCreate(),//reportSelectWork_page.reportCreate(), //'/reportCreate': (context)=> const testRepCreate_page.ReportCreate(),//reportSelectWork_page.reportCreate(),
'/reportCreate': (context)=> const reportSelectWork_page.reportCreate(), '/reportCreate': (context)=> const reportSelectWork_page.reportCreate(),
'/reportList':(context)=> const reportList_page.dailyReportList(), '/reportList':(context)=> const reportList_page.dailyReportList(),
'/reportNew': (context)=>const reportNew_page.reportNew(), '/reportNew': (context)=>const reportNew_page.reportNew(),

View File

@ -21,6 +21,8 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:simple_barcode_scanner/simple_barcode_scanner.dart'; import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
import 'dart:io'; import 'dart:io';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
import 'package:lite_rolling_switch/lite_rolling_switch.dart';
class MainPage extends StatefulWidget { class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key); const MainPage({Key? key}) : super(key: key);
@ -186,7 +188,42 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
if (value==false) if (value==false)
{ {
Navigator.pushNamed(context, '/register', arguments: DeviceArguments( Navigator.pushNamed(context, '/register', arguments: DeviceArguments(
deviceData['id'], deviceData['device'], deviceData['brand'])); deviceData['id'], deviceData['device'], deviceData['brand'])).then((value)
{
Future<String> userApiKey=sc.readSecureData("API");
userApiKey.then((apiKey) => checkApiKeyValidity(apiKey).then((apiKeyState) {
// print("API key State: $apiKeyState");
setState(() {
_isApiKeyValid = apiKeyState;
if (ea.isForeman==true)
{
_reportButtonDisabled=false;
}
if (ea.mobilePortalAccessEnabled==true)
{
NfcManager.instance.isAvailable().then((nfcState){
if (_isApiKeyValid && !_isLocationMocked)
{
_showNFClogo=true;
_tagRead();
}
else
{
_showNFClogo=false;
}
} );
getWorkState(apiKey);
getQRCode(apiKey);
}
_getLocation();
// _getCurrentLocation();
_isApiKeyValid = apiKeyState;
});
}
)
);
});
} }
else else
{ {
@ -216,15 +253,6 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
} ); } );
getWorkState(apiKey); getWorkState(apiKey);
getQRCode(apiKey); getQRCode(apiKey);
/* NfcManager.instance.isAvailable().then((nfcvalue) {
if (nfcvalue) {
_nfcOk = true;
_showNFClogo = true;
if (_location?.isMock == false) {
_tagRead();
}
}
});*/
} }
_getLocation(); _getLocation();
// _getCurrentLocation(); // _getCurrentLocation();
@ -291,16 +319,6 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
} }
/* String _getAppBarTitle() => kIsWeb
? 'Web Browser info'
: switch (defaultTargetPlatform) {
TargetPlatform.android => 'Android DI $apiKeyValid ${_deviceData['id']}',
TargetPlatform.iOS => 'iOS Device Info',
TargetPlatform.linux => 'Linux Device Info',
TargetPlatform.windows => 'Windows Device Info',
TargetPlatform.macOS => 'MacOS Device Info',
TargetPlatform.fuchsia => 'Fuchsia Device Info',
};*/
Widget nfcLogo() { Widget nfcLogo() {
if (_location?.isMock==true) { if (_location?.isMock==true) {
return const Padding( return const Padding(
@ -590,10 +608,12 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
}); });
} }
showQRCode() { showQRCode() {
var _WorkTimeState=false;
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
if (currentWorkState.compareTo('DOLGOZIK')==0) _WorkTimeState=true;
if (currentWorkState.compareTo('VÉGZETT')==0) _WorkTimeState=false;
return AlertDialog( return AlertDialog(
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
@ -640,6 +660,43 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
}, },
), ),
), ),
Container(
padding: const EdgeInsets.all(8.0),
child: LiteRollingSwitch(
value: _WorkTimeState,
width: 200,
textOn: currentWorkState,
textOff: currentWorkState,
colorOn: Colors.deepOrange,
colorOff: Colors.blueGrey,
iconOn: Icons.work,
iconOff: Icons.work_off,
animationDuration: const Duration(milliseconds: 300),
onChanged: (bool state) {
if (kDebugMode) {
print('turned ${(state) ? 'on' : 'off'}');
}
},
onDoubleTap: () {},
onSwipe: () {
if (kDebugMode) {
print('Swiped!');
}
_loginQR(currentQRcode.qrCode);
Navigator.pop(context);
},
onTap: () {},
),
/*ElevatedButton(
child: currentWorkState.compareTo('DOLGOZIK')==0
?const Text('Munkaidő befejezés', style: TextStyle(fontSize: 16))
:const Text('Munkaidő kezdés', style: TextStyle(fontSize: 16),),
onPressed: () {
_loginQR(currentQRcode.qrCode);
Navigator.pop(context);
},
),*/
),
], ],
), ),
), ),
@ -663,13 +720,15 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
title: Text("Mobile Portal V$appCode$appVersion"),//_getAppBarTitle()), title: Text("Mobile Portal V$appCode$appVersion"),//_getAppBarTitle()),
actions: <Widget>[ actions: <Widget>[
IconButton( IconButton(
icon: const Icon(Icons.qr_code), icon: const Icon(Icons.qr_code),
tooltip: 'Show Snackbar', tooltip: 'Bejelentkezés',
onPressed: () { onPressed: (_isApiKeyValid==true && _isLocationValid==true && _isLocationMocked==false) ? () {
getWorkState(employeePageArgs.apiKey as String); getWorkState(employeePageArgs.apiKey as String);
getQRCode(employeePageArgs.apiKey as String); getQRCode(employeePageArgs.apiKey as String);
showQRCode(); showQRCode();
}, }
: null,
), ),
], ],
@ -749,10 +808,11 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
height: 50, height: 50,
//color: Colors.amber, //color: Colors.amber,
child: child:
Column( Column(
children: <Widget>[ children: <Widget>[
Text(currentWorkState), Text(currentWorkState ?? ""),
Text(currentQRcode.name as String, Text(currentQRcode.name ?? "",
style: const TextStyle( style: const TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold fontWeight: FontWeight.bold

View File

@ -143,7 +143,7 @@ class _RegisterPageState extends State<RegisterPage> {
hintText: 'Adja meg KL portal jelszavát!'), hintText: 'Adja meg KL portal jelszavát!'),
), ),
), ),
TextButton( /* TextButton(
onPressed: (){ onPressed: (){
//TODO FORGOT PASSWORD SCREEN GOES HERE //TODO FORGOT PASSWORD SCREEN GOES HERE
}, },
@ -151,6 +151,9 @@ class _RegisterPageState extends State<RegisterPage> {
'Forgot Password', 'Forgot Password',
style: TextStyle(color: Colors.blue, fontSize: 15), style: TextStyle(color: Colors.blue, fontSize: 15),
), ),
),*/
const SizedBox(
width: 10,
), ),
Container( Container(
height: 50, height: 50,

View File

@ -36,7 +36,11 @@ class _ReportCreateState extends State<ReportCreate> {
bool _isError = false; bool _isError = false;
bool _isData = false; bool _isData = false;
final bool _showFaworites = false; final bool _showFaworites = false;
bool _nextEnable=false;
List<EmployeeLs> employeeList = [];
late ReportArguments reportArgs=new ReportArguments([], "", "", false);
late List<WorkListModel> workList = []; late List<WorkListModel> workList = [];
int employeeCount=0;
// late EmployeeArguments empArgs; // late EmployeeArguments empArgs;
Future<void> getSharedPrefs() async { Future<void> getSharedPrefs() async {
@ -63,10 +67,19 @@ class _ReportCreateState extends State<ReportCreate> {
final args = ModalRoute.of(context)!.settings.arguments as Map; final args = ModalRoute.of(context)!.settings.arguments as Map;
employeePageArguments = args['userArgs']; employeePageArguments = args['userArgs'];
//reportArguments = args['dataArgs'];
fetchData(employeePageArguments.apiKey!).then((value) {
setState(() {
employeeList.addAll(value);
employeeList.sort((a,b)=>a.name.compareTo(b.name));
_isData = true;
});
});
}); });
getSharedPrefs().then((value) { getSharedPrefs().then((value) {
fetchdata().then((data) { fetchdata().then((data) {
if (data != null) { if (data != null) {
for (var item in data) { for (var item in data) {
// reportList.add(ModelReportList.fromJson(item)); // reportList.add(ModelReportList.fromJson(item));
workList.add(WorkListModel.fromJson(item)); workList.add(WorkListModel.fromJson(item));
@ -118,13 +131,13 @@ class _ReportCreateState extends State<ReportCreate> {
body: page(context), body: page(context),
bottomNavigationBar: BottomAppBar( /* bottomNavigationBar: BottomAppBar(
color: Colors.cyan, color: Colors.cyan,
child: Container( child: Container(
height: 50.0, height: 50.0,
), ),
) )*/
); );
//visible: _enableSave, //visible: _enableSave,
@ -134,18 +147,35 @@ class _ReportCreateState extends State<ReportCreate> {
Widget page(BuildContext context) { Widget page(BuildContext context) {
_nextEnable=false;
switch(currentStep){
case 0:
if (reportArgs.workId.isNotEmpty) {
_nextEnable=true;
}
break;
case 1:
if (reportArgs.workId.isNotEmpty && employeeCount>0) {
_nextEnable=true;
}
break;
}
return Container( return Container(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(1),
child: Stepper( child: Stepper(
type: StepperType.horizontal, type: StepperType.vertical,
currentStep: currentStep, currentStep: currentStep,
onStepCancel: () => currentStep == 0 onStepCancel: () => currentStep == 0
? null ? null
: setState(() { : setState(() {
currentStep -= 1; currentStep -= 1;
}), }),
onStepContinue: () {
bool isLastStep = (currentStep == getSteps().length - 1); onStepContinue: _nextEnable ?() {
bool isLastStep = (currentStep == getSteps(context).length - 1);
if (isLastStep) { if (isLastStep) {
//Do something with this information //Do something with this information
} else { } else {
@ -153,32 +183,29 @@ class _ReportCreateState extends State<ReportCreate> {
currentStep += 1; currentStep += 1;
}); });
} }
}, }
:null,
onStepTapped: (step) => setState(() { onStepTapped: (step) => setState(() {
currentStep = step; currentStep = step;
}), }),
steps: getSteps(), steps: getSteps(context),
), ),
); );
} }
List<Step> getSteps() { List<Step> getSteps(BuildContext ctx) {
return <Step>[ return <Step>[
Step( Step(
state: currentStep > 0 ? StepState.complete : StepState.indexed, state: currentStep > 0 ? StepState.complete : StepState.indexed,
isActive: currentStep >= 0, isActive: currentStep >= 0,
title: const Text("Ibrányi"), title: const Text("Munka kiválasztása"),
content: selectWork(context) content: selectWork(ctx)
), ),
Step( Step(
state: currentStep > 1 ? StepState.complete : StepState.indexed, state: currentStep > 1 ? StepState.complete : StepState.indexed,
isActive: currentStep >= 1, isActive: currentStep >= 1,
title: const Text("Address"), title: const Text("Address"),
content: const Column( content: empList(context),
children: [
Text("Ibrányi"),
],
),
), ),
Step( Step(
state: currentStep > 2 ? StepState.complete : StepState.indexed, state: currentStep > 2 ? StepState.complete : StepState.indexed,
@ -194,10 +221,14 @@ class _ReportCreateState extends State<ReportCreate> {
} }
Container selectWork(BuildContext context) { Container selectWork(BuildContext ctx) {
return _isData == false return _isData == false
? _isError ? _isError
? Container( ? Container(
height:MediaQuery
.of(ctx)
.size
.height / 1.6,
child: const AlertDialog( child: const AlertDialog(
title: Text('Hálózati Hiba!'), title: Text('Hálózati Hiba!'),
content: Icon(Icons.error_outline), content: Icon(Icons.error_outline),
@ -207,11 +238,11 @@ class _ReportCreateState extends State<ReportCreate> {
: Container( : Container(
child: SizedBox( child: SizedBox(
height: MediaQuery height: MediaQuery
.of(context) .of(ctx)
.size .size
.height / 1.3, .height / 1.6,
width: MediaQuery width: MediaQuery
.of(context) .of(ctx)
.size .size
.width, .width,
child: const Center( child: const Center(
@ -221,31 +252,37 @@ class _ReportCreateState extends State<ReportCreate> {
: gridList(context); : gridList(context);
} }
Container gridList(BuildContext context) { Container gridList(BuildContext ctx) {
//List<ModelReportList> _reportList = []; //List<ModelReportList> _reportList = [];
List<WorkListModel> workList = []; List<WorkListModel> workListl = [];
if (_showFaworites) { if (_showFaworites) {
workList = workList workListl = workList
.where((element) => favoriteWorks.contains(element.sId)) .where((element) => favoriteWorks.contains(element.sId))
.toList(); .toList();
} else { } else {
workList = workList; workListl = workList;
} }
return Container( return Container(
color: const Color(0xffECF0F1),
child: ListView.builder(
itemCount: workList.length, // The length Of the array
padding: const EdgeInsets.all(5), height:MediaQuery
.of(ctx)
.size
.height / 1.6,
//color: const Color(0xffECF0F1),
child: ListView.builder(
itemCount: workListl.length, // The length Of the array
scrollDirection: Axis.vertical,
padding: const EdgeInsets.all(1),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (context, index) => Container( itemBuilder: (ctx, index) => //Container(
child: reportCard(context, workList[index]), // child:
), reportCard(ctx, workListl[index]),
// ),
), ),
); );
} }
Card reportCard(BuildContext context, WorkListModel item) { Card reportCard(BuildContext ctx, WorkListModel item) {
int workHour = 0; int workHour = 0;
bool workOpened = false; bool workOpened = false;
bool isFaworite = favoriteWorks.contains(item.sId); bool isFaworite = favoriteWorks.contains(item.sId);
@ -254,6 +291,7 @@ class _ReportCreateState extends State<ReportCreate> {
workHour += element.employeeList.length; workHour += element.employeeList.length;
});*/ });*/
return Card( return Card(
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Column( child: Column(
children: [ children: [
@ -276,10 +314,11 @@ class _ReportCreateState extends State<ReportCreate> {
? Colors.yellow ? Colors.yellow
: null, : null,
) )
: const Icon(Icons.star_border)), : const Icon(Icons.star_border, color: Colors.yellow)),
onTap: workOpened onTap: workOpened
? () { ? () {
ReportArguments reportArgs = ReportArguments( setState(() {
reportArgs = ReportArguments(
List.empty(), List.empty(),
//userApiKey!, //userApiKey!,
item.title!, item.title!,
@ -288,6 +327,8 @@ class _ReportCreateState extends State<ReportCreate> {
//empArgs.isForeman! //empArgs.isForeman!
); );
});
/** Navigator.pushNamed(context, reportNew.routeName, /** Navigator.pushNamed(context, reportNew.routeName,
arguments: { arguments: {
'userArgs': employeePageArguments, 'userArgs': employeePageArguments,
@ -336,6 +377,55 @@ class _ReportCreateState extends State<ReportCreate> {
), ),
); );
} }
Container empList(BuildContext context) {
//_enableSave = false;
return Container(
height:MediaQuery
.of(context)
.size
.height / 1.6,
color: Colors.white,
child: ListView.builder(
itemCount: employeeList.length, // The length Of the array
scrollDirection: Axis.vertical,
padding: const EdgeInsets.all(1),
shrinkWrap: true,
itemBuilder: (context, index) => Container(
child: Column(children: [
employeeWidget(context, index),
const Divider(
thickness: 1.0,
),
],)
),
),
);
}
SwitchListTile employeeWidget(BuildContext context, index) {
return SwitchListTile(
//controlAffinity: ListTileControlAffinity.trailing,
activeColor: Colors.green,
value: employeeList[index].value,
title: Text(employeeList[index].name, style: const TextStyle(fontSize: 18),),
onChanged: (newValue) {
setState(() {
employeeList[index].value = newValue;
employeeCount=0;
for (var hobby in employeeList) {
if (hobby.value == true) {
//print(hobby.name);
employeeCount++;
}
};
//checkize();
});
});
}
} }

View File

@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1 version: 1.0.2+1
environment: environment:
sdk: '>=3.2.0 <4.0.0' sdk: '>=3.2.0 <4.0.0'
@ -53,6 +53,7 @@ dependencies:
flutter_native_splash: ^2.3.9 flutter_native_splash: ^2.3.9
package_info_plus: ^5.0.1 package_info_plus: ^5.0.1
qr_flutter: ^4.1.0 qr_flutter: ^4.1.0
lite_rolling_switch: ^1.0.1
dev_dependencies: dev_dependencies:
flutter_launcher_icons: ^0.13.1 flutter_launcher_icons: ^0.13.1