Compare commits

..

No commits in common. "main" and "9a3f2f9a9b37fa539282239fde6040e54cb8717d" have entirely different histories.

36 changed files with 6048 additions and 12 deletions

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) 2024 kutafaja
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,3 +0,0 @@
# MobilePortal23
Mobil munkaidő rögzítő app Android

28
analysis_options.yaml Normal file
View File

@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

13
android/.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks

81
android/app/build.gradle Normal file
View File

@ -0,0 +1,81 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
namespace "com.example.mobile_portal_23"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.mobile_portal_23"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
multiDexEnabled = true
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
}

View File

@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.NFC" />
</manifest>

View File

@ -0,0 +1,37 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.NFC" />
<application
android:label="MobilePortal"
android:name="${applicationName}"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

View File

@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

30
android/build.gradle Normal file
View File

@ -0,0 +1,30 @@
buildscript {
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

View File

@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx4G
android.useAndroidX=true
android.enableJetifier=true

29
android/settings.gradle Normal file
View File

@ -0,0 +1,29 @@
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
plugins {
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
}
include ":app"

BIN
assets/cloudlogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
assets/nfc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
assets/nfcdenied.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

14
gradle.properties Normal file
View File

@ -0,0 +1,14 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Thu Nov 23 15:42:22 CET 2023
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M"

View File

@ -0,0 +1,468 @@
import 'package:flutter/material.dart';
import 'package:dropdown_search/dropdown_search.dart';
//import 'package:flutter/rendering.dart';
import 'package:intl/intl.dart';
import '../models/employee_model.dart';
//import '../http_service.dart';
//import '../post_model.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:expandable/expandable.dart';
//import 'package:shared_preferences/shared_preferences.dart';
import 'package:mobile_portal_23/classes/common_classes.dart';
late EmployeePageArguments employeePageArguments;
String appDomain = "iotechnic.eu";
//String appDomain = "192.168.0.144";
GlobalKey _key = GlobalKey();
List<Widget> appbarAct = [
const IconButton(
icon: Icon(Icons.save),
tooltip: 'Open shopping cart',
onPressed: null,
)
];
class DailyReportApp extends StatelessWidget {
final State<StatefulWidget>? homeBodyState = _key.currentState;
DailyReportApp({super.key});
@override
Widget build(BuildContext context) {
return DailyReport(key: key);
/*Scaffold(
appBar: AppBar(
title: Text('Napi Jelentés'),
elevation: 10.0,
leading: Icon(Icons.arrow_back_ios_new),
actions: appbarAct),
body: DailyReport(key: _key),
backgroundColor: Colors.grey[300],
);*/
}
}
class DailyReport extends StatefulWidget {
const DailyReport({Key? key}) : super(key: key);
@override
_DailyReportState createState() => _DailyReportState();
}
class EmpList {
String? id;
String? name;
bool? value;
}
class _DailyReportState extends State<DailyReport> {
//final HttpService httpService = HttpService();
String dropdownValue = 'One';
DateTime selectedDate = DateTime.now();
bool datePickerEnabled = false;
bool textMessageEnabled = false;
bool isSwitched = false;
TextEditingController dateinput = TextEditingController();
List<Widget> switches = [];
List<EmpList> emplist = [];
//Future<List<EmployeeLs>> futureEmployee;
List<EmployeeLs> employeeList = [];
List<WorkLs> workList = [];
bool _isData = false;
String textMessage = "";
// String selectedWork = "";
bool saveEnabled = false;
bool _textMessageOK = false;
WorkLs? selectedWork; // "XST8X8F-6Q9M1FG-PE9948X-SFPHVX9"
String? userApiKey; // = "XST8X8F-6Q9M1FG-PE9948X-SPFHVX9";
final bool _expanded = false;
final bool _appBarSaveEnabled = false;
var currentFocus;
/*Future<Null> getSharedPrefs() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
userApiKey = prefs.getString("apiKey");
}*/
unfocus() {
currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
}
/*_loadApiKey() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getString('apiKey');
}*/
Future fetchdata() async {
print("http://$appDomain/apiGetDailyReport/${employeePageArguments.apiKey!}");
var res = await http.get(
// "http://iotechnic.eu/apiemployeelist/X8B0PQS-2KYMCV3-G5WD74N-8G0CRAH");
Uri.parse("http://$appDomain/apiGetDailyReport/${employeePageArguments.apiKey!}")); //userApiKey!));
//"http://192.168.0.144/apiGetDailyReport/X8B0PQS-2KYMCV3-G5WD74N-8G0CRAH");
if (res.statusCode == 200) {
var obj = json.decode(res.body);
return obj;
}
}
_print(String p) {
print(p);
}
_enableSave() {
setState(() {
appbarAct = [
IconButton(
icon: const Icon(Icons.save),
tooltip: 'Open shopping cart',
onPressed: saveEnabled ? _print("Save Click") : null),
];
});
}
_saveForm() {
EasyLoading.show(status: 'Mentés...');
// _onLoading2();
debugPrint(DateFormat('yyyy-MM-dd').format(selectedDate));
debugPrint("Title: ${selectedWork!.title}");
debugPrint("WorkId: ${selectedWork!.id}");
debugPrint("Message: $textMessage");
List<String> emp = [];
//print("Jelenlévők: ");
for (var hobby in employeeList) {
if (hobby.value == true) {
//print(hobby.name);
emp.add(hobby.id);
}
}
var report = {
'userApiKey': userApiKey,
'workId': selectedWork?.id,
'date': DateFormat('yyyy.MM.dd').format(selectedDate),
'msg': textMessage,
'employeeList': emp
};
//print(json.encode(report));
postDailyReport(report).then((value) {
if (value.contains("OK")) {
EasyLoading.showSuccess('Sikeres Mentés');
Future.delayed(const Duration(seconds: 3), () {
// Navigator.pop(context); //pop dialog
EasyLoading.dismiss();
Navigator.of(context).pop();
//_login();
});
}
});
}
Future<String> postDailyReport(var json) async {
final response = await http.post(
Uri.parse("http://$appDomain/apiPostDailyReport/${employeePageArguments.apiKey!}"),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(json),
);
if (response.statusCode == 200) {
// If the server did return a 201 CREATED response,
// then parse the JSON.
return response.body;
} else {
// If the server did not return a 201 CREATED response,
// then throw an exception.
throw Exception('Failed to create album.');
}
}
@override
initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
final args = ModalRoute.of(context)!.settings.arguments as Map;
employeePageArguments = args['userArgs'];
// empArgs = (ModalRoute.of(context)?.settings.arguments ??
// <String, dynamic>{}) as EmployeeArguments;
// getSharedPrefs().then((value) {
});
print("KEY: ${employeePageArguments.apiKey}");
fetchdata().then((data) {
for (var item in data["employeeList"]) {
//debugPrint(item["_id"]);
employeeList.add(EmployeeLs(
id: item["_id"], name: item["name"], value: false));
}
for (var item in data["workList"]) {
debugPrint(item["_id"]);
workList.add(WorkLs(
id: item["_id"],
title: item["title"],
body: item["body"],
state: item["state"] ??"",
//value: false
));
}
_isData = true;
setState(() {
debugPrint('Fetch ok.');
});
//employeeList = data;
});
//userApiKey = _loadApiKey();
_enableSave();
//_isData = false;
dateinput.text = ""; //set the initial value of text field
}
@override
void dispose() {
// Clean up the controller when the widget is removed from the
// widget tree.
super.dispose();
}
Column myUi() {
saveEnabled = false;
_enableSave();
//debugPrint("UI Update." + _isData.toString());
return Column(
children: employeeList.map((hobby) {
if (hobby.value == true) {
saveEnabled = true;
_enableSave();
// debugPrint(hobby.name);
}
return SwitchListTile(
//controlAffinity: ListTileControlAffinity.trailing,
activeColor: Colors.green,
value: hobby.value,
title: Text(hobby.name),
onChanged: _textMessageOK == false
? null
: (newValue) {
setState(() {
hobby.value = newValue;
});
});
}).toList());
}
DropdownSearch workUi() {
return DropdownSearch<WorkLs>(
//mode: Mode.MENU,
//showSelectedItem: true,
items: workList,
/*.map((e) {
return DropdownMenuItem<WorkLs>(child: Text(e.title), value: e);
}).toList(),*/
//showSearchBox: true,
//;["Brazil", "Italia (Disabled)", "Tunisia", 'Canada'],
//label: "Munka kiválasztása",
// hint: "country in menu mode",
//popupItemDisabled: (String s) => s.startsWith('I'),
onChanged: (data) {
//_dateSelected();
selectedWork = data;
//_selectDate(context);
setState(() {
datePickerEnabled = true;
});
});
}
@override
Widget build(BuildContext context) => GestureDetector(
onTap: () {
//_enableSave();
FocusScope.of(context).unfocus();
},
child: Scaffold(
appBar: AppBar(
title: const Text('Napi Jelentés'),
elevation: 10.0,
leading: const Icon(Icons.arrow_back_ios_new),
actions: [
IconButton(
icon: const Icon(Icons.save),
tooltip: 'Open shopping cart',
onPressed: saveEnabled ? _print("Save Click") : null),
]),
//body: DailyReport(key: _key),
backgroundColor: Colors.grey[300],
body: SingleChildScrollView(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
//itemExtent: 100,
// shrinkWrap: true,
child:
//saveBegin == true
// ? _onLoading()
//: _isData == false
_isData == false
? SizedBox(
height: MediaQuery.of(context).size.height / 1.3,
width: MediaQuery.of(context).size.width,
child: const Center(
child: CircularProgressIndicator(),
),
)
: Column(
//diameterRatio: 10,
children: <Widget>[
Container(
padding: const EdgeInsets.all(15),
height: 100,
child: workUi(),
),
Container(
padding: const EdgeInsets.only(left: 10, right: 10),
child: Center(
child: TextField(
enabled: datePickerEnabled,
controller:
dateinput, //editing controller of this TextField
decoration: const InputDecoration(
icon: Icon(Icons
.calendar_today), //icon of text field
labelText:
"Jelentés Dátuma" //label text of field
),
readOnly:
true, //set it true, so that user will not able to edit text
onTap: () async {
DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(
2000), //DateTime.now() - not to allow to choose before today.
lastDate: DateTime.now());
if (pickedDate != null) {
print(
pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
String formattedDate =
DateFormat('yyyy.MM.dd')
.format(pickedDate);
print(
formattedDate); //formatted date output using intl package => 2021-03-16
//you can implement different kind of Date Format here according to your requirement
setState(() {
textMessageEnabled = true;
selectedDate = pickedDate;
dateinput.text =
formattedDate; //set output date to TextField value.
});
} else {
print("Nem választott dátumot!");
}
},
)),
),
Container(
padding: const EdgeInsets.only(
top: 20, left: 15, right: 15),
//margin: const EdgeInsets.only(left: 5, right: 5),
height: 100,
//child: Padding(
//padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
child: TextField(
enabled: textMessageEnabled,
//keyboardType: TextInputType.multiline,
maxLines: null,
onSubmitted: (value) => {
textMessage = value,
(value.length > 3) == true
? _textMessageOK = true
: _textMessageOK = false,
},
//expands: true,
textInputAction: TextInputAction.done,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Munkafolyamat leírása',
),
/* onChanged: (value) => {
textMessage = value,
(value.length > 3) == true
? _textMessageOK = true
: _textMessageOK = false,
//myUi.call()
}*/
)),
//),
// The checkboxes will be here
Container(
padding: const EdgeInsets.only(left: 10, right: 10),
child: Card(
//elevation: 2,
child: ExpandablePanel(
header: Container(
height: 35,
padding: const EdgeInsets.all(5),
color: Colors.indigo,
child: const Text(
"Jelenlévők kiválasztása",
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
collapsed:
const Text("Érintse a lenyitáshoz."),
expanded: AbsorbPointer(
absorbing: !_textMessageOK,
child: myUi(),
)
// tapHeaderToExpand: true,
//hasIcon: true,
))
/* Column(children: [
ListTile(
title: const Text(
"Jelenlévők",
style: TextStyle(fontWeight: FontWeight.bold),
),
leading: Icon(Icons.arrow_drop_down_circle),
//onTap: ,
),
_isData == false
? Center(child: new CircularProgressIndicator())
: myUi(),
]),*/
),
Container(
padding: const EdgeInsets.all(20),
child: Center(
child: ElevatedButton.icon(
onPressed: saveEnabled ? _saveForm : null,
icon: const Icon(Icons.save),
label: const Text('Save')),
// something like 2013-04-20
//Text(DateFormat('yyyy.MM.dd').format(selectedDate))
),
),
],
))));
}

View File

@ -0,0 +1,207 @@
import 'package:flutter/material.dart';
import 'package:mobile_portal_23/classes/common_classes.dart';
//import 'package:shared_preferences/shared_preferences.dart';
//late EmployeeArguments empArgs;
String? userApiKey; // = "XST8X8F-6Q9M1FG-PE9948X-SPFHVX9";
bool _error = false;
late EmployeePageArguments employeePageArguments;
class reportNav extends StatefulWidget {
const reportNav({Key? key}) : super(key: key);
@override
State<reportNav> createState() => _reportNavState();
}
/*
Future<http.Response> fetchData(String userApiKey) async {
var url = "http://" + appDomain + "/apiemployee/" + userApiKey;
http.Response response = await http.get(Uri.parse(url));
return response;
//return resp.map<EmployeeLs>((m) => EmployeeLs.fromJson(m)).toList();
}
*/
Future<void> _showMyDialog(BuildContext cont) async {
return showDialog<void>(
context: cont,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Mobile Portal'),
content: const Text("Nem található érvényes api Key."),
actions: <Widget>[
TextButton(
child: const Text('Bezárás'),
onPressed: () {
Navigator.pop(cont);
},
),
],
);
},
);
}
class _reportNavState extends State<reportNav> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
final args = ModalRoute.of(context)!.settings.arguments as Map;
employeePageArguments = args['userArgs'];
// empArgs = (ModalRoute.of(context)?.settings.arguments ??
// <String, dynamic>{}) as EmployeeArguments;
// getSharedPrefs().then((value) {
});
//print("KEY: ${employeePageArguments.apiKey}");
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
/*Future<Null> getSharedPrefs() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
userApiKey = prefs.getString("apiKey");
if (userApiKey == null) {
_error = true;
WidgetsBinding.instance!
.addPostFrameCallback((timeStamp) => _showMyDialog(context));
}
if (userApiKey!.length != 31) {
_error = true;
WidgetsBinding.instance!
.addPostFrameCallback((timeStamp) => _showMyDialog(context));
}
}*/
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Jelentések"),
/* actions: [
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.more_vert,
),
onPressed: () {},
)
],*/
actionsIconTheme: const IconThemeData(
size: 32,
),
),
//drawer: Drawer(),
body: _error ? Container() : page(context));
}
}
Container page(BuildContext context) {
final args = ModalRoute.of(context)!.settings.arguments as Map;
EmployeePageArguments employeePageArguments = args['userArgs'];
if (employeePageArguments.apiKey == null) {
_showMyDialog(context);
}
return Container(
child: GridView.count(
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 2,
shrinkWrap: true,
padding: const EdgeInsets.only(top: 24, left: 24, right: 24),
children: <Widget>[
/* MaterialButton(
onPressed: () {
Navigator.pushNamed(context, '/newDailyReport');
},
color: Colors.blue,
textColor: Colors.white,
child: Column(
children: [
Icon(
Icons.add,
size: 48,
),
Text(
"Új jelentés",
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.bold),
)
],
),
padding: EdgeInsets.only(top: 32.0),
//shape: RoundedRectangleBorder(side:,borderRadius: Radius())), // CircleBorder(),
),*/
MaterialButton(
onPressed: () {
Navigator.pushNamed(context, '/reportList', arguments: {
'userArgs': employeePageArguments,
'dataArgs': null
});
},
color: Colors.blue,
textColor: Colors.white,
padding: const EdgeInsets.only(top: 32.0),
child: const Column(
children: [
Icon(
Icons.list,
size: 48,
),
Text(
"Jelentések",
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.bold),
)
],
),
//shape: RoundedRectangleBorder(side:,borderRadius: Radius())), // CircleBorder(),
),
MaterialButton(
onPressed: () {
Navigator.pushNamed(context, '/reportCreate', arguments: {
'userArgs': employeePageArguments,
'dataArgs': null
});
},
color: Colors.blue,
textColor: Colors.white,
padding: const EdgeInsets.only(top: 32.0),
child: const Column(
children: [
Icon(
Icons.add,
size: 48,
),
Text(
"Új jelentés",
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.bold),
)
],
),
//shape: RoundedRectangleBorder(side:,borderRadius: Radius())), // CircleBorder(),
),
],
),
);
}

View File

@ -0,0 +1,765 @@
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'dart:convert';
import 'package:mobile_portal_23/models/workTimeDetailsModel.dart';
import 'package:mobile_portal_23/classes/common_classes.dart';
import 'package:http/http.dart' as http;
import 'package:jiffy/jiffy.dart';
extension on Duration {
String format(String s) => '$this'.split('.')[0].padLeft(8, '0');
}
class workTimeDetails extends StatefulWidget {
const workTimeDetails({Key? key}) : super(key: key);
static const routeName = '/wtdetails';
@override
State<workTimeDetails> createState() => _workTimeDetailsState();
}
late EmployeePageArguments employeePageArguments;
late WorkTimeDetailsModel workTimeList;
bool _isError = false;
bool _isData = false;
final DateFormat nowformat = DateFormat('yyyy.MM');
class _workTimeDetailsState extends State<workTimeDetails> {
final DateFormat formatter = DateFormat('yyyy MMMM');
DateTime selectedDate = DateTime.now();
String appDomain = "iotechnic.eu";
@override
void initState() {
super.initState();
initializeDateFormatting('hu');
WidgetsBinding.instance.addPostFrameCallback((_) {
final args = ModalRoute.of(context)!.settings.arguments as Map;
employeePageArguments = args['userArgs'];
// empArgs = (ModalRoute.of(context)?.settings.arguments ??
// <String, dynamic>{}) as EmployeeArguments;
// getSharedPrefs().then((value) {
reloadData(nowformat.format(selectedDate));
});
// });
}
reloadData(String date) {
fetchdata(date).then((data) {
if (data != null) {
// for (var item in data) {
workTimeList =
WorkTimeDetailsModel.fromJson(data); //{'wd': data['wd']}));
// }
setState(() {
_isData = true;
debugPrint('Fetch ok.');
});
} else {
_isError = true;
}
//employeeList = data;
});
}
Future fetchdata(String date) async {
var res = await http.get(
// "http://iotechnic.eu/apiGetAllReport/X8B0PQS-2KYMCV3-G5WD74N-8G0CRAH");
Uri.parse("http://$appDomain/employee/androidAccessList/${employeePageArguments.apiKey!}/$date"));
//"http://192.168.0.144/apiGetDailyReport/X8B0PQS-2KYMCV3-G5WD74N-8G0CRAH");
if (res.statusCode == 200) {
var obj = json.decode(res.body);
return obj;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: _isData ? Text(formatter.format(selectedDate)) : const Text("ss"),
elevation: 10.0,
actions: <Widget>[
IconButton(
icon: const Icon(Icons.navigate_before),
tooltip: 'Show Snackbar',
onPressed: () {
selectedDate = Jiffy.parse(selectedDate.toString()).subtract(months: 1).dateTime;
reloadData(nowformat.format(selectedDate));
}),
IconButton(
icon: const Icon(Icons.navigate_next_rounded),
color: Colors.white,
tooltip: 'Go to the next page',
onPressed: selectedDate.difference(DateTime.now()).inDays < 0
? () {
_isData = false;
_isError = false;
selectedDate = Jiffy.parse(selectedDate.toString()).add(months: 1).dateTime;
// String jiffy=selectedDate.
reloadData(nowformat.format(selectedDate));
}
: null,
),
],
// leading: Icon(Icons.arrow_back_ios_new),
),
body: _isData
? detailsPage(
context, workTimeList) //reportCard(context, workTimeList)
: const Center(child: CircularProgressIndicator()),
backgroundColor: Colors.grey[300],
);
}
String minToTime(var seconds) {
int minutes = (seconds / 60).truncate();
int sec = (seconds % 60);
String minutesStr = "${minutes.toString().padLeft(2, "0")}.${sec.toString().padLeft(2, "0")}";
return minutesStr;
}
/* Widget _buildContent(BuildContext context) {
return Container(
color: Color(0xffECF0F1),
child: ListView.builder(
itemCount: workTimeList
.length, //workTimeList.wd?.length, // The length Of the array
padding: EdgeInsets.all(5),
shrinkWrap: true,
itemBuilder: (context, index) => Container(
child: //if (_isData)
reportCard(context, workTimeList, index)),
));
}*/
Widget Arrive(e, Wd wtd) {
var dateformat = DateFormat.E('hu');
final DateFormat formatter = DateFormat('HH:mm');
return //Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
/* Expanded(
// flex: 1,
child: Text(
wtd.date!.substring(8, 11).toString(),
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black87),
)),
Expanded(
//flex: 1,
child: Text(
//"$item.month.fullWorkHours",
wtd.isHoliday == true
? dateformat
.format(DateFormat("yyyy.MM.DD").parse(wtd.date.toString()))
: dateformat
.format(DateFormat("yyyy.MM.DD.").parse(wtd.date.toString())),
//item.month?.fullWorkHours.toString(),
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, color: Colors.blue),
)),*/
Expanded(
flex: 8,
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(
'É: ${formatter.format(DateFormat("H:mm")
.parse(e.start.substring(12, e.start.length)))} ' +
e.arriveLoc,
overflow: TextOverflow.ellipsis),
if (e.stop == '-')
const Text('--:--')
else
Text(
'T: ${formatter.format(DateFormat("H:mm")
.parse(e.stop.substring(12, e.stop.length)))} ' +
e.getawayLoc,
overflow: TextOverflow.ellipsis),
]));
}
Container startStopWidget(BuildContext context, Wd wtd) {
var dateformat = DateFormat.E('hu');
final DateFormat formatter = DateFormat('HH:mm');
List<Widget> v = [];
v.add(Expanded(
// flex: 1,
child: Text(
wtd.date!.substring(8, 10).toString(),
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black87),
)));
v.add(
Expanded(
//flex: 1,
child: Text(
//"$item.month.fullWorkHours",
wtd.isHoliday == true
? dateformat
.format(DateFormat("yyyy.MM.DD").parse(wtd.date.toString()))
: dateformat
.format(DateFormat("yyyy.MM.DD.").parse(wtd.date.toString())),
//item.month?.fullWorkHours.toString(),
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, color: Colors.blue),
)),
);
if (wtd.isHoliday == false) {
for (var e in wtd.startStop!) {
v.add(Expanded(
flex: 8,
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(
'É: ${formatter.format(DateFormat("yyyy.MM.dd. H:mm")
.parse(e.start.toString()))} ${e.arriveLoc}',
overflow: TextOverflow.ellipsis),
if (e.stop == '-')
const Text('--:--')
else
Text(
'T: ${formatter.format(DateFormat("yyyy.MM.dd. H:mm")
.parse(e.stop.toString()))} ${e.getawayLoc}',
overflow: TextOverflow.ellipsis),
])));
debugPrint(wtd.toString());
}
}
return Container(
color: const Color.fromARGB(255, 206, 206, 206),
margin: const EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: wtd.isHoliday == true
? [
Text(wtd.date.toString()),
const Text("Szabadság"),
const Divider(
thickness: 1.0,
),
]
: //wtd.startStop!.map((e) => Arrive(e, wtd)).toList()),
[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children:
v /*[
Expanded(
// flex: 1,
child: Text(
wtd.date!.substring(8, 11).toString(),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.black87),
)
),
Expanded(
//flex: 1,
child: Text(
//"$item.month.fullWorkHours",
wtd.isHoliday == true
? dateformat.format(DateFormat("yyyy.MM.DD")
.parse(wtd.date.toString()))
: dateformat.format(DateFormat("yyyy.MM.DD.")
.parse(wtd.date.toString())),
//item.month?.fullWorkHours.toString(),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue),
)
),
wtd.startStop!.map((e) => Arrive(e, wtd)).toList()),
]*/
)
]));
}
Container detailsPage(BuildContext context, WorkTimeDetailsModel item) {
return Container(
child: ListView.builder(
itemCount: item.wd!.length,
itemBuilder: (BuildContext context, int index) {
_isData = false;
return //startStopWidget(context, item.wd![index]);
//reportCard2(context, item.wd![index]);
buildCard(context, item.wd![index]);
},
));
}
Widget buildCard(BuildContext context, Wd itemx) {
var dayformat = DateFormat.d('hu');
var dateformat = DateFormat.E('hu');
final DateFormat formatter = DateFormat('HH:mm');
return Padding(
padding: const EdgeInsets.all(10),
child: Card(
child: Padding(
padding: const EdgeInsets.all(10),
child: ExpandablePanel(
header: Column(children: [
Row(
children: [
Text(
itemx.isHoliday == true
? '${dayformat.format(DateFormat("yyyy.MM.dd")
.parse(itemx.date.toString()))}.'
: '${dayformat.format(DateFormat("yyyy.MM.dd.")
.parse(itemx.date.toString()))}.',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.black),
),
const SizedBox(
width: 10,
),
Text(
//"$item.month.fullWorkHours",
itemx.isHoliday == true
? dateformat.format(DateFormat("yyyy.MM.dd")
.parse(itemx.date.toString()))
: dateformat.format(DateFormat("yyyy.MM.dd.")
.parse(itemx.date.toString())),
//item.month?.fullWorkHours.toString(),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue),
),
],
),
const Divider(
color: Colors.blue,
thickness: 1,
)
]),
//Text("Header"),
collapsed: //Text('collapsed'),
itemx.isHoliday == true
? const Text("Szabadság")
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
//Text(itemx.fullHours.toString()),
Text('Normál óra'),
Text('Túlóra óra'),
Text('Összes óra'),
]),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text(
formatter.format(DateFormat("mm")
.parse(itemx.hours.toString())),
textAlign: TextAlign.center),
Text(
formatter.format(DateFormat("mm")
.parse(itemx.overTime.toString())),
textAlign: TextAlign.center),
Text(
formatter.format(DateFormat("mm")
.parse(itemx.fullHours.toString())),
textAlign: TextAlign.center),
]),
]),