import 'package:dart_eval/dart_eval.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; import 'package:json_annotation/json_annotation.dart'; /// This allows the `User` class to access private members in /// the generated file. The value for this is *.g.dart, where /// the star denotes the source file name. part 'calisma_kayit.g.dart'; enum GunTuru { CALISMA_GUNU, DINLENME_GUNU, HAFTA_TATILI } /// An annotation for the code generator to know that this class needs the /// JSON serialization logic to be generated. @collection @JsonSerializable() class CalismaKayit { CalismaKayit({this.id = 0}); int id; DateTime? tarih = null; GunTuru gunTuru = GunTuru.CALISMA_GUNU; DateTime? giris; DateTime? cikis; List? molalar; int? calismaSuresiInSeconds; @ignore Duration? get calismaSuresi => calismaSuresiInSeconds != null ? Duration(microseconds: calismaSuresiInSeconds!) : null; set calismaSuresi(Duration? value) => calismaSuresiInSeconds = value?.inMicroseconds; double? mesaiCarpani = 1.0; bool servisGecikmesi = false; bool resmiTatil = false; bool raporlu = false; bool gunlukIzinli = false; bool yillikIzinli = false; bool yolParasiVar = false; bool yemekParasiVar = false; bool kartKaydedilebilir() { if (giris == null && ((gunTuru == GunTuru.HAFTA_TATILI || gunTuru == GunTuru.DINLENME_GUNU) || resmiTatil || gunlukIzinli || raporlu || yillikIzinli)) { return true; } if ((giris != null && cikis == null) && (gunlukIzinli || raporlu || yillikIzinli)) { return true; } if (giris != null && cikis == null && ((gunTuru == GunTuru.HAFTA_TATILI || gunTuru == GunTuru.DINLENME_GUNU) || resmiTatil)) { return false; } if (giris == null && cikis == null) { return false; } if ((giris != null && cikis != null)) { return true; } return false; } girisYap() { DateTime sonuc = DateTime.now(); final program = r''' class Cat { Cat(this.name); final String name; String speak() => "I'm $name!"; } String main() { final cat = Cat('Fluffy'); return cat.name; } '''; print(eval(program, function: 'main')); } /// A necessary factory constructor for creating a new User instance /// from a map. Pass the map to the generated `_$UserFromJson()` constructor. /// The constructor is named after the source class, in this case, User. factory CalismaKayit.fromJson(Map json) => _$CalismaKayitFromJson(json); /// `toJson` is the convention for a class to declare support for serialization /// to JSON. The implementation simply calls the private, generated /// helper method `_$UserToJson`. Map toJson() => _$CalismaKayitToJson(this); } @embedded @JsonSerializable() class Mola { Mola(); String? ismi; String? aciklama; @TimeOfDayConverter() DateTime? baslamaZamani; @TimeOfDayConverter() DateTime? bitisZamani; int? sure; bool? caslimaSaatindenDus; bool? bildirimGoster; bool? otomatikGir; /// A necessary factory constructor for creating a new User instance /// from a map. Pass the map to the generated `_$UserFromJson()` constructor. /// The constructor is named after the source class, in this case, User. factory Mola.fromJson(Map json) => _$MolaFromJson(json); /// `toJson` is the convention for a class to declare support for serialization /// to JSON. The implementation simply calls the private, generated /// helper method `_$UserToJson`. Map toJson() => _$MolaToJson(this); } class TimeOfDayConverter implements JsonConverter { const TimeOfDayConverter(); @override TimeOfDay fromJson(String json) { final parts = json.split(':'); final hour = int.parse(parts[0]); final minute = int.parse(parts[1]); return TimeOfDay(hour: hour, minute: minute); } @override String toJson(TimeOfDay object) { return '${object.hour.toString().padLeft(2, '0')}:${object.minute.toString().padLeft(2, '0')}'; } } /** AYRAÇ: İsar Db İçin Alttakiler */ // @collection // class aktifKart { // aktifKart({required this.id}); // int id; // DateTime? tarih; // GunTuru gunTuru = GunTuru.CALISMA_GUNU; // DateTime? giris; // DateTime? cikis; // List? molalar; // int? calismaSuresiInSeconds; // @ignore // Duration? get calismaSuresi => calismaSuresiInSeconds != null // ? Duration(seconds: calismaSuresiInSeconds!) // : null; // set calismaSuresi(Duration? value) => // calismaSuresiInSeconds = value?.inSeconds; // double? mesaiCarpani = 1.0; // bool servisGecikmesi = false; // bool resmiTatil = false; // bool raporlu = false; // bool gunlukIzinli = false; // bool yillikIzinli = false; // bool yolParasiVar = false; // bool yemekParasiVar = false; // } // @embedded // class Mola1 { // Mola1(); // String? ismi; // String? aciklama; // DateTime? baslamaZamani; // DateTime? bitisZamani; // int? sure; // bool? caslimaSaatindenDus; // bool? bildirimGoster; // bool? otomatikGir; // } // @embedded // class Recipient { // String? name; // String? address; // }