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) {
final DateFormat formatter = DateFormat('HH:mm');
var start = DateFormat("yyyy.MM.dd. HH:mm").parse(e.start.toString());
DateTime stop;
DateTime stop=DateTime(2024);
late Duration diff;
if (e.stop != '-') {
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/reportDetails.dart' as reportDetails_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() {
runApp(const MyApp());
}
@ -47,7 +48,7 @@ class MyApp extends StatelessWidget {
'/':(context)=>const main_page.MainPage(),
'/wtdetails': (context) => const worktime_page.workTimeDetails(),
'/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(),
'/reportList':(context)=> const reportList_page.dailyReportList(),
'/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 'dart:io';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:lite_rolling_switch/lite_rolling_switch.dart';
class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key);
@ -186,7 +188,42 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
if (value==false)
{
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
{
@ -216,15 +253,6 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
} );
getWorkState(apiKey);
getQRCode(apiKey);
/* NfcManager.instance.isAvailable().then((nfcvalue) {
if (nfcvalue) {
_nfcOk = true;
_showNFClogo = true;
if (_location?.isMock == false) {
_tagRead();
}
}
});*/
}
_getLocation();
// _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() {
if (_location?.isMock==true) {
return const Padding(
@ -590,10 +608,12 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
});
}
showQRCode() {
var _WorkTimeState=false;
showDialog(
context: context,
builder: (context) {
if (currentWorkState.compareTo('DOLGOZIK')==0) _WorkTimeState=true;
if (currentWorkState.compareTo('VÉGZETT')==0) _WorkTimeState=false;
return AlertDialog(
shape: const RoundedRectangleBorder(
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()),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.qr_code),
tooltip: 'Show Snackbar',
onPressed: () {
tooltip: 'Bejelentkezés',
onPressed: (_isApiKeyValid==true && _isLocationValid==true && _isLocationMocked==false) ? () {
getWorkState(employeePageArgs.apiKey as String);
getQRCode(employeePageArgs.apiKey as String);
showQRCode();
},
}
: null,
),
],
@ -749,10 +808,11 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
height: 50,
//color: Colors.amber,
child:
Column(
children: <Widget>[
Text(currentWorkState),
Text(currentQRcode.name as String,
Text(currentWorkState ?? ""),
Text(currentQRcode.name ?? "",
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold

View File

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

View File

@ -36,7 +36,11 @@ class _ReportCreateState extends State<ReportCreate> {
bool _isError = false;
bool _isData = false;
final bool _showFaworites = false;
bool _nextEnable=false;
List<EmployeeLs> employeeList = [];
late ReportArguments reportArgs=new ReportArguments([], "", "", false);
late List<WorkListModel> workList = [];
int employeeCount=0;
// late EmployeeArguments empArgs;
Future<void> getSharedPrefs() async {
@ -63,10 +67,19 @@ class _ReportCreateState extends State<ReportCreate> {
final args = ModalRoute.of(context)!.settings.arguments as Map;
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) {
fetchdata().then((data) {
if (data != null) {
for (var item in data) {
// reportList.add(ModelReportList.fromJson(item));
workList.add(WorkListModel.fromJson(item));
@ -118,13 +131,13 @@ class _ReportCreateState extends State<ReportCreate> {
body: page(context),
bottomNavigationBar: BottomAppBar(
/* bottomNavigationBar: BottomAppBar(
color: Colors.cyan,
child: Container(
height: 50.0,
),
)
)*/
);
//visible: _enableSave,
@ -134,18 +147,35 @@ class _ReportCreateState extends State<ReportCreate> {
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(
padding: const EdgeInsets.all(20),
padding: const EdgeInsets.all(1),
child: Stepper(
type: StepperType.horizontal,
type: StepperType.vertical,
currentStep: currentStep,
onStepCancel: () => currentStep == 0
? null
: setState(() {
currentStep -= 1;
}),
onStepContinue: () {
bool isLastStep = (currentStep == getSteps().length - 1);
onStepContinue: _nextEnable ?() {
bool isLastStep = (currentStep == getSteps(context).length - 1);
if (isLastStep) {
//Do something with this information
} else {
@ -153,32 +183,29 @@ class _ReportCreateState extends State<ReportCreate> {
currentStep += 1;
});
}
},
}
:null,
onStepTapped: (step) => setState(() {
currentStep = step;
}),
steps: getSteps(),
steps: getSteps(context),
),
);
}
List<Step> getSteps() {
List<Step> getSteps(BuildContext ctx) {
return <Step>[
Step(
state: currentStep > 0 ? StepState.complete : StepState.indexed,
isActive: currentStep >= 0,
title: const Text("Ibrányi"),
content: selectWork(context)
title: const Text("Munka kiválasztása"),
content: selectWork(ctx)
),
Step(
state: currentStep > 1 ? StepState.complete : StepState.indexed,
isActive: currentStep >= 1,
title: const Text("Address"),
content: const Column(
children: [
Text("Ibrányi"),
],
),
content: empList(context),
),
Step(
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
? _isError
? Container(
height:MediaQuery
.of(ctx)
.size
.height / 1.6,
child: const AlertDialog(
title: Text('Hálózati Hiba!'),
content: Icon(Icons.error_outline),
@ -207,11 +238,11 @@ class _ReportCreateState extends State<ReportCreate> {
: Container(
child: SizedBox(
height: MediaQuery
.of(context)
.of(ctx)
.size
.height / 1.3,
.height / 1.6,
width: MediaQuery
.of(context)
.of(ctx)
.size
.width,
child: const Center(
@ -221,31 +252,37 @@ class _ReportCreateState extends State<ReportCreate> {
: gridList(context);
}
Container gridList(BuildContext context) {
Container gridList(BuildContext ctx) {
//List<ModelReportList> _reportList = [];
List<WorkListModel> workList = [];
List<WorkListModel> workListl = [];
if (_showFaworites) {
workList = workList
workListl = workList
.where((element) => favoriteWorks.contains(element.sId))
.toList();
} else {
workList = workList;
workListl = workList;
}
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,
itemBuilder: (context, index) => Container(
child: reportCard(context, workList[index]),
),
itemBuilder: (ctx, index) => //Container(
// child:
reportCard(ctx, workListl[index]),
// ),
),
);
}
Card reportCard(BuildContext context, WorkListModel item) {
Card reportCard(BuildContext ctx, WorkListModel item) {
int workHour = 0;
bool workOpened = false;
bool isFaworite = favoriteWorks.contains(item.sId);
@ -254,6 +291,7 @@ class _ReportCreateState extends State<ReportCreate> {
workHour += element.employeeList.length;
});*/
return Card(
clipBehavior: Clip.antiAlias,
child: Column(
children: [
@ -276,10 +314,11 @@ class _ReportCreateState extends State<ReportCreate> {
? Colors.yellow
: null,
)
: const Icon(Icons.star_border)),
: const Icon(Icons.star_border, color: Colors.yellow)),
onTap: workOpened
? () {
ReportArguments reportArgs = ReportArguments(
setState(() {
reportArgs = ReportArguments(
List.empty(),
//userApiKey!,
item.title!,
@ -288,6 +327,8 @@ class _ReportCreateState extends State<ReportCreate> {
//empArgs.isForeman!
);
});
/** Navigator.pushNamed(context, reportNew.routeName,
arguments: {
'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
# 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.
version: 1.0.0+1
version: 1.0.2+1
environment:
sdk: '>=3.2.0 <4.0.0'
@ -53,6 +53,7 @@ dependencies:
flutter_native_splash: ^2.3.9
package_info_plus: ^5.0.1
qr_flutter: ^4.1.0
lite_rolling_switch: ^1.0.1
dev_dependencies:
flutter_launcher_icons: ^0.13.1