feat: přidat projekt
This commit is contained in:
commit
95b26b4063
42 changed files with 5261 additions and 0 deletions
76
lib/main.dart
Normal file
76
lib/main.dart
Normal file
|
@ -0,0 +1,76 @@
|
|||
import 'package:denikprogramatora/okna/signin_page.dart';
|
||||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
|
||||
import 'firebase_options.dart'; //TODO: Přidejte si vlastní firebase nastavení
|
||||
|
||||
/*
|
||||
Copyright (C) 2022 Matyáš Caras a Richard Pavlikán
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions
|
||||
.currentPlatform, //TODO: Přidejte si vlastní firebase nastavení
|
||||
);
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ResponsiveSizer(
|
||||
builder: (p0, p1, p2) => MaterialApp(
|
||||
title: 'Deník Programátora',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
scaffoldBackgroundColor: Vzhled.backgroundColor,
|
||||
textTheme: Theme.of(context).textTheme.apply(
|
||||
bodyColor: Vzhled.textColor,
|
||||
displayColor: Vzhled.textColor,
|
||||
fontSizeDelta: 2,
|
||||
fontSizeFactor: 0.8,
|
||||
),
|
||||
colorScheme: const ColorScheme(
|
||||
background: Vzhled.dialogColor,
|
||||
onBackground: Vzhled.textColor,
|
||||
brightness: Brightness.dark,
|
||||
primary: Colors.blue,
|
||||
onPrimary: Vzhled.textColor,
|
||||
secondary: Colors.purple,
|
||||
onSecondary: Vzhled.textColor,
|
||||
error: Colors.red,
|
||||
onError: Vzhled.textColor,
|
||||
surface: Vzhled.backgroundColor,
|
||||
onSurface: Vzhled.textColor),
|
||||
dialogBackgroundColor: Vzhled.dialogColor,
|
||||
),
|
||||
localizationsDelegates: const [
|
||||
...GlobalMaterialLocalizations.delegates
|
||||
],
|
||||
supportedLocales: const [Locale("cs")],
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: const SignInPage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
722
lib/okna/all_records.dart
Normal file
722
lib/okna/all_records.dart
Normal file
|
@ -0,0 +1,722 @@
|
|||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:denikprogramatora/okna/app.dart';
|
||||
import 'package:denikprogramatora/okna/settings.dart';
|
||||
import 'package:denikprogramatora/okna/signin_page.dart';
|
||||
import 'package:denikprogramatora/utils/devicecontainer.dart';
|
||||
import 'package:denikprogramatora/utils/input_decoration.dart';
|
||||
import 'package:denikprogramatora/utils/loading_widget.dart';
|
||||
import 'package:denikprogramatora/utils/months.dart';
|
||||
import 'package:denikprogramatora/utils/my_category.dart';
|
||||
import 'package:denikprogramatora/utils/my_container.dart';
|
||||
import 'package:denikprogramatora/utils/new_record_dialog.dart';
|
||||
import 'package:denikprogramatora/utils/programmer.dart';
|
||||
import 'package:denikprogramatora/utils/show_info_dialog.dart';
|
||||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
/*
|
||||
Copyright (C) 2022 Matyáš Caras a Richard Pavlikán
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class AllRecordsPage extends StatefulWidget {
|
||||
const AllRecordsPage({super.key});
|
||||
|
||||
@override
|
||||
State<AllRecordsPage> createState() => _AllRecordsPageState();
|
||||
}
|
||||
|
||||
class _AllRecordsPageState extends State<AllRecordsPage> {
|
||||
bool _loading = true;
|
||||
Month mesic = months[0];
|
||||
int selectedDay = DateTime.now().day;
|
||||
int year = DateTime.now().year;
|
||||
|
||||
List<MyCategory> categories = [MyCategory("Nic", "nic")];
|
||||
List<Programmer> programmers = [
|
||||
const Programmer("Nic", "nic"),
|
||||
Programmer(name, userUid)
|
||||
];
|
||||
List filterJazyky = [
|
||||
{"jazyk": "Nic", "barva": 0xff8200f3},
|
||||
];
|
||||
|
||||
late String selectedCategory;
|
||||
late String selectedProgrammer;
|
||||
bool newestToOldest = true;
|
||||
late String selectedJazyk;
|
||||
DateTime fromDate =
|
||||
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day);
|
||||
DateTime toDate =
|
||||
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day);
|
||||
|
||||
bool searchByFromDate = false;
|
||||
bool searchByToDate = false;
|
||||
|
||||
int timeHour = 0;
|
||||
int timeMinute = 0;
|
||||
int review = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (FirebaseAuth.instance.currentUser == null) {
|
||||
if (kDebugMode) print("user should not be here");
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(builder: (c) => const SignInPage()),
|
||||
(route) => false);
|
||||
return;
|
||||
}
|
||||
|
||||
name = FirebaseAuth.instance.currentUser!.displayName!;
|
||||
|
||||
ref.collection("programmers").get().then((value) {
|
||||
for (var snap in value.docs) {
|
||||
var data = snap.data();
|
||||
|
||||
programmers.add(Programmer(data["name"], snap.id));
|
||||
}
|
||||
});
|
||||
|
||||
ref.collection("categories").get().then((value) {
|
||||
for (var snap in value.docs) {
|
||||
var data = snap.data();
|
||||
categories.add(MyCategory(data["name"], snap.id));
|
||||
}
|
||||
});
|
||||
|
||||
filterJazyky.addAll(jazyky);
|
||||
|
||||
selectedCategory = categories[0].id;
|
||||
selectedProgrammer = programmers[0].id;
|
||||
selectedJazyk = "Nic";
|
||||
|
||||
mesic = months[DateTime.now().month - 1];
|
||||
|
||||
setState(() {
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 90.w,
|
||||
child: (_loading)
|
||||
? const LoadingWidget()
|
||||
: CustomScrollView(
|
||||
slivers: [
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyContainer(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 90.w
|
||||
: 35.w,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (name != "error") Text("Ahoj $name"),
|
||||
TextButton(
|
||||
onPressed: () => showAboutDialog(
|
||||
context: context,
|
||||
applicationName: "Kodelog",
|
||||
applicationVersion: "1.1.0",
|
||||
applicationLegalese:
|
||||
"©️ 2023 Matyáš Caras a Richard Pavlikán,\n vydáno pod licencí AGPLv3",
|
||||
children: [
|
||||
TextButton(
|
||||
child: const Text("Zdrojový kód"),
|
||||
onPressed: () => launchUrlString(
|
||||
"https://github.com/Royal-Buccaneers/kodelog"),
|
||||
)
|
||||
]),
|
||||
child: const Text(
|
||||
"Licence",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (c) =>
|
||||
const SignInPage()),
|
||||
(route) => false);
|
||||
},
|
||||
child: const Text(
|
||||
"Odhlásit se",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
MyContainer(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 90.w
|
||||
: 40.w,
|
||||
child: DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const HlavniOkno()));
|
||||
},
|
||||
child: const Text(
|
||||
"Denní přehled",
|
||||
style:
|
||||
TextStyle(color: Vzhled.textColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
"Všechny\nzáznamy",
|
||||
style: TextStyle(
|
||||
color: Vzhled.textColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const NastaveniOkno()));
|
||||
},
|
||||
child: const Text(
|
||||
"Nastavení",
|
||||
style:
|
||||
TextStyle(color: Vzhled.textColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
OutlinedButton(
|
||||
onPressed: () =>
|
||||
showCreateItemDialog(context),
|
||||
style: Vzhled.orangeCudlik,
|
||||
child: const Text(
|
||||
"Přidat záznam",
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: MyContainer(
|
||||
width: 90.w,
|
||||
child: DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width:
|
||||
(Device.screenType == ScreenType.mobile)
|
||||
? 80.w
|
||||
: 40.w,
|
||||
child: Column(
|
||||
children: [
|
||||
const Text("Filtr",
|
||||
style: Vzhled.nadpis),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
"Záznamy seřazené od ${newestToOldest ? "nejnovějších po nejstarší" : "nejstarších po nejnovější"}"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
newestToOldest =
|
||||
!newestToOldest;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Změnit",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
DeviceContainer(
|
||||
children: [
|
||||
const Text("Kategorie"),
|
||||
const SizedBox(width: 15),
|
||||
DropdownButton(
|
||||
value: selectedCategory,
|
||||
items: categories.map((e) {
|
||||
return DropdownMenuItem(
|
||||
value: e.id,
|
||||
child: Text(e.name));
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedCategory = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
DeviceContainer(
|
||||
children: [
|
||||
const Text("Jazyk"),
|
||||
const SizedBox(width: 15),
|
||||
DropdownButton(
|
||||
value: selectedJazyk,
|
||||
dropdownColor:
|
||||
Vzhled.backgroundColor,
|
||||
items: filterJazyky
|
||||
.map(
|
||||
(e) => DropdownMenuItem(
|
||||
value: e["jazyk"],
|
||||
child: Text(e["jazyk"]),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedJazyk =
|
||||
(value as String?)!;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
DeviceContainer(
|
||||
children: [
|
||||
const Text("Programátor"),
|
||||
const SizedBox(width: 15),
|
||||
DropdownButton(
|
||||
value: selectedProgrammer,
|
||||
items: programmers.map((e) {
|
||||
return DropdownMenuItem(
|
||||
value: e.id,
|
||||
child: Text(e.name));
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedProgrammer = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
DeviceContainer(
|
||||
children: [
|
||||
const Text("Strávený čas"),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
width: 75,
|
||||
child: TextField(
|
||||
decoration:
|
||||
inputDecoration("Hodin"),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
timeHour =
|
||||
value.trim().isEmpty
|
||||
? 0
|
||||
: int.parse(value);
|
||||
});
|
||||
},
|
||||
keyboardType:
|
||||
TextInputType.number,
|
||||
inputFormatters: <
|
||||
TextInputFormatter>[
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
SizedBox(
|
||||
width: 75,
|
||||
child: TextField(
|
||||
decoration:
|
||||
inputDecoration("Minut"),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
timeMinute =
|
||||
value.trim().isEmpty
|
||||
? 0
|
||||
: int.parse(value);
|
||||
});
|
||||
},
|
||||
keyboardType:
|
||||
TextInputType.number,
|
||||
inputFormatters: <
|
||||
TextInputFormatter>[
|
||||
FilteringTextInputFormatter
|
||||
.digitsOnly
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
if (timeMinute != 0 ||
|
||||
timeHour != 0)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
timeMinute = 0;
|
||||
timeHour = 0;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Zrušit filtr",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
DeviceContainer(
|
||||
children: [
|
||||
const Text("Hodnocení"),
|
||||
const SizedBox(width: 15),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: List.generate(
|
||||
5,
|
||||
(index) {
|
||||
return IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
review = index + 1;
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.star,
|
||||
color: (index + 1) <=
|
||||
review
|
||||
? Colors.yellow
|
||||
: Colors.grey),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (review != 0)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
review = 0;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Zrušit filtr",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
const Text("Od: "),
|
||||
const SizedBox(width: 15),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate: fromDate,
|
||||
firstDate: DateTime(
|
||||
DateTime.now()
|
||||
.year -
|
||||
5),
|
||||
lastDate: DateTime(
|
||||
DateTime.now()
|
||||
.year +
|
||||
5))
|
||||
.then((value) {
|
||||
setState(() {
|
||||
fromDate = value!;
|
||||
searchByFromDate = true;
|
||||
});
|
||||
}).onError(
|
||||
(error, stackTrace) =>
|
||||
null);
|
||||
},
|
||||
child: Text(searchByFromDate
|
||||
? "${fromDate.day}.${fromDate.month}.${fromDate.year}"
|
||||
: "Vybrat den"),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
if (searchByFromDate)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
searchByFromDate = false;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
("Zrušit filtr"),
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Row(
|
||||
children: [
|
||||
const Text("Do: "),
|
||||
const SizedBox(width: 15),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate: toDate,
|
||||
firstDate: DateTime(
|
||||
DateTime.now()
|
||||
.year -
|
||||
5),
|
||||
lastDate: DateTime(
|
||||
DateTime.now()
|
||||
.year +
|
||||
5))
|
||||
.then((value) {
|
||||
setState(() {
|
||||
toDate = value!;
|
||||
searchByToDate = true;
|
||||
});
|
||||
}).onError(
|
||||
(error, stackTrace) =>
|
||||
null);
|
||||
},
|
||||
child: Text(searchByToDate
|
||||
? "${toDate.day}.${toDate.month}.${toDate.year}"
|
||||
: "Vybrat den"),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
if (searchByToDate)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
searchByToDate = false;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
("Zrušit filtr"),
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
(Device.screenType == ScreenType.mobile)
|
||||
? 80.w
|
||||
: 40.w,
|
||||
child: StreamBuilder(
|
||||
stream: ref
|
||||
.collection("records")
|
||||
.orderBy("fromDate",
|
||||
descending: newestToOldest)
|
||||
.snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
var docs = snapshot.data!.docs;
|
||||
|
||||
if (selectedProgrammer != "nic") {
|
||||
docs = docs
|
||||
.where((element) =>
|
||||
element
|
||||
.data()["programmer"] ==
|
||||
selectedProgrammer)
|
||||
.toList();
|
||||
}
|
||||
|
||||
if (selectedCategory != "nic") {
|
||||
docs = docs
|
||||
.where((element) => (element
|
||||
.data()[
|
||||
"categories"] as List)
|
||||
.contains(selectedCategory))
|
||||
.toList();
|
||||
}
|
||||
|
||||
if (selectedJazyk != "Nic") {
|
||||
docs = docs
|
||||
.where((element) =>
|
||||
element.data()["language"]
|
||||
["jazyk"] ==
|
||||
selectedJazyk)
|
||||
.toList();
|
||||
}
|
||||
|
||||
if (searchByFromDate) {
|
||||
docs = docs
|
||||
.where((d) =>
|
||||
(d.data()["fromDate"]
|
||||
as Timestamp)
|
||||
.toDate()
|
||||
.compareTo(
|
||||
fromDate) ==
|
||||
1 ||
|
||||
(d.data()["fromDate"]
|
||||
as Timestamp)
|
||||
.toDate()
|
||||
.compareTo(
|
||||
fromDate) ==
|
||||
0)
|
||||
.toList();
|
||||
}
|
||||
|
||||
if (searchByToDate) {
|
||||
docs = docs
|
||||
.where((d) =>
|
||||
(d.data()["toDate"]
|
||||
as Timestamp)
|
||||
.toDate()
|
||||
.compareTo(
|
||||
toDate) ==
|
||||
-1 ||
|
||||
(d.data()["toDate"]
|
||||
as Timestamp)
|
||||
.toDate()
|
||||
.compareTo(
|
||||
toDate) ==
|
||||
0)
|
||||
.toList();
|
||||
}
|
||||
|
||||
if (timeHour != 0 ||
|
||||
timeMinute != 0) {
|
||||
if (kDebugMode) {
|
||||
print(
|
||||
"${timeHour == 0 ? "" : (timeHour == 1 ? "$timeHour hodina" : "$timeHour hodin")}${timeMinute == 0 ? "" : (timeMinute == 1 ? "a $timeMinute minuta" : " a $timeMinute minut")}");
|
||||
}
|
||||
docs = docs
|
||||
.where((element) => (element
|
||||
.data()["codingTime"] ==
|
||||
"${timeHour == 0 ? "" : (timeHour == 1 ? "$timeHour hodina" : "$timeHour hodin")}${timeMinute == 0 ? "" : (timeMinute == 1 ? "a $timeMinute minuta" : " a $timeMinute minut")}"))
|
||||
.toList();
|
||||
}
|
||||
|
||||
if (review != 0) {
|
||||
docs = docs
|
||||
.where((element) =>
|
||||
element.data()["review"] ==
|
||||
review)
|
||||
.toList();
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: List.generate(
|
||||
docs.length,
|
||||
(index) {
|
||||
var data = docs[index].data();
|
||||
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
const BorderRadius
|
||||
.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
color: Color(
|
||||
data["language"]
|
||||
["barva"]),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () =>
|
||||
showInfoDialog(
|
||||
context,
|
||||
data,
|
||||
docs[index].id),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"${(data["fromDate"] as Timestamp).toDate().year}.${(data["fromDate"] as Timestamp).toDate().month}.${(data["fromDate"] as Timestamp).toDate().day} ${(data["fromDate"] as Timestamp).toDate().hour < 10 ? "0${(data["fromDate"] as Timestamp).toDate().hour}" : (data["fromDate"] as Timestamp).toDate().hour}:${(data["fromDate"] as Timestamp).toDate().minute < 10 ? "0${(data["fromDate"] as Timestamp).toDate().minute}" : (data["fromDate"] as Timestamp).toDate().minute}"),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Text(
|
||||
" - ${data["language"]["jazyk"]}")
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
return const LoadingWidget();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
554
lib/okna/app.dart
Normal file
554
lib/okna/app.dart
Normal file
|
@ -0,0 +1,554 @@
|
|||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:denikprogramatora/okna/all_records.dart';
|
||||
import 'package:denikprogramatora/okna/settings.dart';
|
||||
import 'package:denikprogramatora/okna/signin_page.dart';
|
||||
import 'package:denikprogramatora/utils/devicecontainer.dart';
|
||||
import 'package:denikprogramatora/utils/loading_widget.dart';
|
||||
import 'package:denikprogramatora/utils/months.dart';
|
||||
import 'package:denikprogramatora/utils/my_container.dart';
|
||||
import 'package:denikprogramatora/utils/new_record_dialog.dart';
|
||||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../utils/razeni.dart';
|
||||
import '../utils/show_info_dialog.dart';
|
||||
|
||||
/*
|
||||
Copyright (C) 2022 Matyáš Caras a Richard Pavlikán
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var ref = FirebaseFirestore.instance
|
||||
.collection("users")
|
||||
.doc(FirebaseAuth.instance.currentUser!.uid);
|
||||
String name = "error";
|
||||
String userUid = "error";
|
||||
|
||||
class HlavniOkno extends StatefulWidget {
|
||||
const HlavniOkno({super.key});
|
||||
|
||||
@override
|
||||
State<HlavniOkno> createState() => _HlavniOknoState();
|
||||
}
|
||||
|
||||
class _HlavniOknoState extends State<HlavniOkno> {
|
||||
bool _loading = true;
|
||||
|
||||
Month mesic = months[0];
|
||||
int selectedDay = DateTime.now().day;
|
||||
int year = DateTime.now().year;
|
||||
int vybraneRazeni = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (FirebaseAuth.instance.currentUser == null) {
|
||||
if (kDebugMode) print("user should not be here");
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(builder: (c) => const SignInPage()),
|
||||
(route) => false);
|
||||
return;
|
||||
}
|
||||
|
||||
userUid = FirebaseAuth.instance.currentUser!.uid;
|
||||
name = FirebaseAuth.instance.currentUser!.displayName!;
|
||||
|
||||
mesic = months[DateTime.now().month - 1];
|
||||
|
||||
setState(() {
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 90.w,
|
||||
child: (_loading)
|
||||
? const LoadingWidget()
|
||||
: CustomScrollView(
|
||||
slivers: [
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: Column(
|
||||
children: [
|
||||
DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyContainer(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 90.w
|
||||
: 35.w,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (name != "error") Text("Ahoj $name"),
|
||||
TextButton(
|
||||
onPressed: () => showAboutDialog(
|
||||
context: context,
|
||||
applicationName: "Kodelog",
|
||||
applicationVersion: "1.1.0",
|
||||
applicationLegalese:
|
||||
"©️ 2023 Matyáš Caras a Richard Pavlikán,\n vydáno pod licencí AGPLv3",
|
||||
children: [
|
||||
TextButton(
|
||||
child: const Text("Zdrojový kód"),
|
||||
onPressed: () => launchUrlString(
|
||||
"https://github.com/Royal-Buccaneers/kodelog"),
|
||||
)
|
||||
]),
|
||||
child: const Text(
|
||||
"Licence",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
if (!mounted) return;
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (c) =>
|
||||
const SignInPage()),
|
||||
(route) => false);
|
||||
},
|
||||
child: const Text(
|
||||
"Odhlásit se",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
MyContainer(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 95.w
|
||||
: 45.w,
|
||||
child: DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
"Denní přehled",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Vzhled.textColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const AllRecordsPage()));
|
||||
},
|
||||
child: const Text(
|
||||
"Všechny\nzáznamy",
|
||||
style:
|
||||
TextStyle(color: Vzhled.textColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const NastaveniOkno()));
|
||||
},
|
||||
child: const Text(
|
||||
"Nastavení",
|
||||
style:
|
||||
TextStyle(color: Vzhled.textColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
OutlinedButton(
|
||||
onPressed: () =>
|
||||
showCreateItemDialog(context),
|
||||
style: Vzhled.orangeCudlik,
|
||||
child: const Text(
|
||||
"Přidat záznam",
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: MyContainer(
|
||||
width: 90.w,
|
||||
child: DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 40.w,
|
||||
child: StreamBuilder(
|
||||
stream:
|
||||
ref.collection("records").snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
var docs = snapshot.data!.docs;
|
||||
var jenMesic = docs
|
||||
.where((d) =>
|
||||
DateTime.parse(
|
||||
"$year-${(mesic.position + 1 < 10) ? "0${mesic.position + 1}" : mesic.position + 1}-${selectedDay < 10 ? "0$selectedDay" : selectedDay} 00:00:00")
|
||||
.isBefore(
|
||||
(d.data()["toDate"]
|
||||
as Timestamp)
|
||||
.toDate()) &&
|
||||
DateTime.parse(
|
||||
"$year-${(mesic.position + 1 < 10) ? "0${mesic.position + 1}" : mesic.position + 1}-${selectedDay < 10 ? "0$selectedDay" : selectedDay} 23:59:59")
|
||||
.isAfter(
|
||||
(d.data()["fromDate"]
|
||||
as Timestamp)
|
||||
.toDate()))
|
||||
.toList() // vybere pouze záznamy, které probíhají ve vybraný den
|
||||
..sort(
|
||||
razeni[vybraneRazeni],
|
||||
); // seřadíme podle vybrané metody řazení
|
||||
if (jenMesic.isEmpty) {
|
||||
return const Text(
|
||||
"Nic",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 25),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: List.generate(
|
||||
jenMesic.length,
|
||||
(index) {
|
||||
var data =
|
||||
jenMesic[index].data();
|
||||
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
const BorderRadius
|
||||
.all(
|
||||
Radius.circular(4),
|
||||
),
|
||||
color: Color(
|
||||
data["language"]
|
||||
["barva"]),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () =>
|
||||
showInfoDialog(
|
||||
context,
|
||||
data,
|
||||
jenMesic[index]
|
||||
.id),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"${(data["fromDate"] as Timestamp).toDate().hour < 10 ? "0${(data["fromDate"] as Timestamp).toDate().hour}" : (data["fromDate"] as Timestamp).toDate().hour}:${(data["fromDate"] as Timestamp).toDate().minute < 10 ? "0${(data["fromDate"] as Timestamp).toDate().minute}" : (data["fromDate"] as Timestamp).toDate().minute}"),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
Text(
|
||||
" - ${data["language"]["jazyk"]}")
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
return const LoadingWidget();
|
||||
},
|
||||
),
|
||||
),
|
||||
if (Device.screenType == ScreenType.mobile)
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
SizedBox(
|
||||
width: 45.w,
|
||||
child: Column(
|
||||
children: [
|
||||
DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
const Text("Řazení:"),
|
||||
DropdownButton(
|
||||
items: const [
|
||||
DropdownMenuItem<int>(
|
||||
value: 0,
|
||||
child: Text(
|
||||
"Vzestupně dle času"),
|
||||
),
|
||||
DropdownMenuItem<int>(
|
||||
value: 1,
|
||||
child:
|
||||
Text("Sestupně dle času"),
|
||||
),
|
||||
DropdownMenuItem<int>(
|
||||
value: 2,
|
||||
child: Text(
|
||||
"Vzestupně dle hodnocení"),
|
||||
),
|
||||
DropdownMenuItem<int>(
|
||||
value: 3,
|
||||
child: Text(
|
||||
"Sestupně dle hodnocení"),
|
||||
),
|
||||
],
|
||||
value: vybraneRazeni,
|
||||
onChanged: (v) {
|
||||
if (v == null) return;
|
||||
|
||||
vybraneRazeni = v;
|
||||
setState(() {});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
if (Device.screenType !=
|
||||
ScreenType.mobile)
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(
|
||||
() {
|
||||
if (mesic.position -
|
||||
1 !=
|
||||
-1) {
|
||||
mesic = months[
|
||||
mesic.position -
|
||||
1];
|
||||
} else {
|
||||
mesic = months[11];
|
||||
year--;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.arrow_back,
|
||||
color: Vzhled.purple),
|
||||
),
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${mesic.name} $year",
|
||||
style: Vzhled.velkyText,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (mesic.position +
|
||||
1 !=
|
||||
12) {
|
||||
mesic = months[
|
||||
mesic.position +
|
||||
1];
|
||||
} else {
|
||||
mesic = months[0];
|
||||
year++;
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.arrow_forward,
|
||||
color: Vzhled.purple),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
calendarView()
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
if (Device.screenType == ScreenType.mobile)
|
||||
Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(
|
||||
() {
|
||||
if (mesic.position - 1 !=
|
||||
-1) {
|
||||
mesic = months[
|
||||
mesic.position - 1];
|
||||
} else {
|
||||
mesic = months[11];
|
||||
year--;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back,
|
||||
color: Vzhled.purple),
|
||||
),
|
||||
SizedBox(
|
||||
width: 150,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${mesic.name} $year",
|
||||
style: Vzhled.velkyText,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (mesic.position + 1 !=
|
||||
12) {
|
||||
mesic = months[
|
||||
mesic.position + 1];
|
||||
} else {
|
||||
mesic = months[0];
|
||||
year++;
|
||||
}
|
||||
});
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.arrow_forward,
|
||||
color: Vzhled.purple),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
calendarView()
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget calendarView() {
|
||||
int day = 1;
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(
|
||||
((mesic.days / 7) == 4
|
||||
? (Device.screenType == ScreenType.mobile)
|
||||
? 10
|
||||
: 4
|
||||
: (Device.screenType == ScreenType.mobile)
|
||||
? 11
|
||||
: 5),
|
||||
(index) {
|
||||
return Row(
|
||||
mainAxisAlignment: (Device.screenType == ScreenType.mobile)
|
||||
? MainAxisAlignment.center
|
||||
: MainAxisAlignment.start,
|
||||
children: List.generate(
|
||||
(Device.screenType == ScreenType.mobile) ? 3 : 7,
|
||||
(index) {
|
||||
int thisDay = day++;
|
||||
|
||||
if (thisDay > mesic.days) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: OutlinedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
selectedDay = thisDay;
|
||||
});
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: (selectedDay == thisDay)
|
||||
? Vzhled.purple
|
||||
: Colors.black.withOpacity(0),
|
||||
foregroundColor: (selectedDay == thisDay)
|
||||
? Vzhled.backgroundColor
|
||||
: Vzhled.textColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
),
|
||||
side: BorderSide(
|
||||
color: (selectedDay != thisDay)
|
||||
? Vzhled.purple
|
||||
: Colors.black.withOpacity(0))),
|
||||
child: Text(thisDay.toString()),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
306
lib/okna/settings.dart
Normal file
306
lib/okna/settings.dart
Normal file
|
@ -0,0 +1,306 @@
|
|||
import 'package:denikprogramatora/okna/app.dart';
|
||||
import 'package:denikprogramatora/okna/signin_page.dart';
|
||||
import 'package:denikprogramatora/utils/devicecontainer.dart';
|
||||
import 'package:denikprogramatora/utils/loading_widget.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../utils/my_container.dart';
|
||||
import '../utils/new_record_dialog.dart';
|
||||
import '../utils/vzhled.dart';
|
||||
import 'all_records.dart';
|
||||
|
||||
/*
|
||||
Copyright (C) 2022 Matyáš Caras a Richard Pavlikán
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class NastaveniOkno extends StatefulWidget {
|
||||
const NastaveniOkno({super.key});
|
||||
|
||||
@override
|
||||
State<NastaveniOkno> createState() => _NastaveniOknoState();
|
||||
}
|
||||
|
||||
class _NastaveniOknoState extends State<NastaveniOkno> {
|
||||
var _loading = true;
|
||||
var name = "error";
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (FirebaseAuth.instance.currentUser == null) {
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(builder: (c) => const SignInPage()),
|
||||
(route) => false);
|
||||
return;
|
||||
}
|
||||
name = FirebaseAuth.instance.currentUser!.displayName!;
|
||||
|
||||
setState(() {
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 90.w,
|
||||
height: 100.h,
|
||||
child: (_loading)
|
||||
? const LoadingWidget()
|
||||
: Column(children: [
|
||||
DeviceContainer(
|
||||
mainAxisAlignmentDesktop: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyContainer(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 90.w
|
||||
: 35.w,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (name != "error") Text("Ahoj $name"),
|
||||
TextButton(
|
||||
onPressed: () => showAboutDialog(
|
||||
context: context,
|
||||
applicationName: "Kodelog",
|
||||
applicationVersion: "1.1.0",
|
||||
applicationLegalese:
|
||||
"©️ 2023 Matyáš Caras a Richard Pavlikán,\n vydáno pod licencí AGPLv3",
|
||||
children: [
|
||||
TextButton(
|
||||
child: const Text("Zdrojový kód"),
|
||||
onPressed: () => launchUrlString(
|
||||
"https://github.com/Royal-Buccaneers/kodelog"),
|
||||
)
|
||||
]),
|
||||
child: const Text(
|
||||
"Licence",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
if (!mounted) return;
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (c) => const SignInPage()),
|
||||
(route) => false);
|
||||
},
|
||||
child: const Text(
|
||||
"Odhlásit se",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
MyContainer(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 90.w
|
||||
: 40.w,
|
||||
child: DeviceContainer(
|
||||
mainAxisAlignmentDesktop:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacement(MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const HlavniOkno())),
|
||||
child: const Text(
|
||||
"Denní přehled",
|
||||
style: TextStyle(color: Vzhled.textColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const AllRecordsPage()));
|
||||
},
|
||||
child: const Text(
|
||||
"Všechny\nzáznamy",
|
||||
style: TextStyle(color: Vzhled.textColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
"Nastavení",
|
||||
style: TextStyle(
|
||||
color: Vzhled.textColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
OutlinedButton(
|
||||
onPressed: () => showCreateItemDialog(context),
|
||||
style: Vzhled.orangeCudlik,
|
||||
child: const Text(
|
||||
"Přidat záznam",
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Expanded(
|
||||
child: MyContainer(
|
||||
width: 90.w,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(
|
||||
10,
|
||||
),
|
||||
),
|
||||
color: Vzhled.purple,
|
||||
),
|
||||
width: 400,
|
||||
child: InkWell(
|
||||
onTap: () => showProgrammersDialog(context,
|
||||
jenMenit: true),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Text(
|
||||
"Upravit programátory",
|
||||
style: Vzhled.nadpis,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(
|
||||
10,
|
||||
),
|
||||
),
|
||||
color: Vzhled.purple),
|
||||
width: 400,
|
||||
child: InkWell(
|
||||
onTap: () => showCategoriesDialog(context, [],
|
||||
jenMenit: true),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Text(
|
||||
"Upravit kategorie",
|
||||
style: Vzhled.nadpis,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(
|
||||
10,
|
||||
),
|
||||
),
|
||||
color: Vzhled.purple),
|
||||
width: 400,
|
||||
child: InkWell(
|
||||
onTap: () => showEditJazyk(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Text(
|
||||
"Oblíbený jazyk",
|
||||
style: Vzhled.nadpis,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
))
|
||||
]),
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
showEditJazyk() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text("Oblíbený jazyk", style: Vzhled.velkyText),
|
||||
scrollable: true,
|
||||
content: SizedBox(
|
||||
width: 20.w,
|
||||
child: StreamBuilder(
|
||||
stream: ref.snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return DropdownButton(
|
||||
value: snapshot.data!.data()!["favourite"],
|
||||
dropdownColor: Vzhled.backgroundColor,
|
||||
items: jazyky
|
||||
.map(
|
||||
(e) => DropdownMenuItem(
|
||||
value: e["jazyk"],
|
||||
child: SizedBox(
|
||||
width: 17.w, child: Text(e["jazyk"])),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
ref.update({"favourite": value!});
|
||||
});
|
||||
}
|
||||
return const LoadingWidget();
|
||||
}),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
436
lib/okna/signin_page.dart
Normal file
436
lib/okna/signin_page.dart
Normal file
|
@ -0,0 +1,436 @@
|
|||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:denikprogramatora/okna/app.dart';
|
||||
import 'package:denikprogramatora/utils/loading_widget.dart';
|
||||
import 'package:denikprogramatora/utils/my_container.dart';
|
||||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
/*
|
||||
Copyright (C) 2022 Matyáš Caras a Richard Pavlikán
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class SignInPage extends StatefulWidget {
|
||||
const SignInPage({super.key});
|
||||
|
||||
@override
|
||||
State<SignInPage> createState() => _SignInPageState();
|
||||
}
|
||||
|
||||
class _SignInPageState extends State<SignInPage> {
|
||||
bool showSignIn = true;
|
||||
bool isLoading = true;
|
||||
|
||||
TextEditingController emailCon = TextEditingController();
|
||||
TextEditingController passwordCon = TextEditingController();
|
||||
TextEditingController nameCon = TextEditingController();
|
||||
|
||||
String jazyk = "C#";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
if (FirebaseAuth.instance.currentUser != null) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (c) => const HlavniOkno()),
|
||||
);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: isLoading
|
||||
? const LoadingWidget()
|
||||
: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: showSignIn ? signInWidget() : registerWidget(),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
left: 10,
|
||||
child: TextButton(
|
||||
onPressed: () => showAboutDialog(
|
||||
context: context,
|
||||
applicationName: "Kodelog",
|
||||
applicationVersion: "1.1.0",
|
||||
applicationLegalese:
|
||||
"©️ 2023 Matyáš Caras a Richard Pavlikán,\n vydáno pod licencí AGPLv3",
|
||||
children: [
|
||||
TextButton(
|
||||
child: const Text("Zdrojový kód"),
|
||||
onPressed: () => launchUrlString(
|
||||
"https://github.com/Royal-Buccaneers/kodelog"),
|
||||
)
|
||||
]),
|
||||
child: const Text(
|
||||
"Licence",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget signInWidget() {
|
||||
GlobalKey<FormState> form = GlobalKey<FormState>();
|
||||
return MyContainer(
|
||||
height: 70.h,
|
||||
width: (Device.screenType == ScreenType.mobile) ? 80.w : 40.w,
|
||||
child: Form(
|
||||
key: form,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Kodelog",
|
||||
style: TextStyle(fontSize: 20.sp, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
SizedBox(
|
||||
width: (Device.screenType == ScreenType.mobile) ? 60.w : 30.w,
|
||||
child: TextFormField(
|
||||
decoration: Vzhled.inputDecoration("E-mail"),
|
||||
cursorColor: Vzhled.textColor,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
autocorrect: false,
|
||||
controller: emailCon,
|
||||
onFieldSubmitted: (_) {
|
||||
if (form.currentState!.validate()) {
|
||||
signIn();
|
||||
}
|
||||
},
|
||||
validator: (value) {
|
||||
if (value!.trim().isEmpty) {
|
||||
return "Toto pole je povinné!";
|
||||
} else if (!RegExp(r'[\w\.]+@[a-z0-9]+\.[a-z]{1,3}')
|
||||
.hasMatch(value)) {
|
||||
return "Neplatný e-mail!";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: (Device.screenType == ScreenType.mobile) ? 60.w : 30.w,
|
||||
child: TextFormField(
|
||||
decoration: Vzhled.inputDecoration("Heslo"),
|
||||
cursorColor: Vzhled.textColor,
|
||||
autocorrect: false,
|
||||
obscureText: true,
|
||||
controller: passwordCon,
|
||||
onFieldSubmitted: (_) {
|
||||
if (form.currentState!.validate()) {
|
||||
signIn();
|
||||
}
|
||||
},
|
||||
validator: (value) {
|
||||
if (value!.trim().isEmpty) {
|
||||
return "Toto pole je povinné!";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
OutlinedButton(
|
||||
style: Vzhled.orangeCudlik,
|
||||
onPressed: () {
|
||||
if (form.currentState!.validate()) {
|
||||
signIn();
|
||||
}
|
||||
},
|
||||
child: const Text("Přihlásit se"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text("nebo"),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showSignIn = false;
|
||||
});
|
||||
},
|
||||
child: const Text("Registrovat se", style: Vzhled.textBtn),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget registerWidget() {
|
||||
GlobalKey<FormState> form = GlobalKey<FormState>();
|
||||
return MyContainer(
|
||||
width: (Device.screenType == ScreenType.mobile) ? 80.w : 40.w,
|
||||
child: Form(
|
||||
key: form,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Kodelog",
|
||||
style: TextStyle(fontSize: 20.sp, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
SizedBox(
|
||||
width: (Device.screenType == ScreenType.mobile) ? 60.w : 30.w,
|
||||
child: TextFormField(
|
||||
decoration: Vzhled.inputDecoration("Jméno"),
|
||||
cursorColor: Vzhled.textColor,
|
||||
controller: nameCon,
|
||||
onFieldSubmitted: (_) {
|
||||
if (form.currentState!.validate()) {
|
||||
signUp();
|
||||
}
|
||||
},
|
||||
validator: (value) {
|
||||
if (value!.trim().isEmpty) {
|
||||
return "Toto pole je povinné!";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: (Device.screenType == ScreenType.mobile) ? 60.w : 30.w,
|
||||
child: TextFormField(
|
||||
decoration: Vzhled.inputDecoration("E-mail"),
|
||||
cursorColor: Vzhled.textColor,
|
||||
controller: emailCon,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
autocorrect: false,
|
||||
onFieldSubmitted: (_) {
|
||||
if (form.currentState!.validate()) {
|
||||
signUp();
|
||||
}
|
||||
},
|
||||
validator: (value) {
|
||||
if (value!.trim().isEmpty) {
|
||||
return "Toto pole je povinné!";
|
||||
} else if (!RegExp(r'[\w\.]+@[a-z0-9]+\.[a-z]{1,3}')
|
||||
.hasMatch(value)) {
|
||||
return "Neplatný e-mail!";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: (Device.screenType == ScreenType.mobile) ? 60.w : 30.w,
|
||||
child: TextFormField(
|
||||
decoration: Vzhled.inputDecoration("Heslo"),
|
||||
cursorColor: Vzhled.textColor,
|
||||
obscureText: true,
|
||||
controller: passwordCon,
|
||||
onFieldSubmitted: (_) {
|
||||
if (form.currentState!.validate()) {
|
||||
signUp();
|
||||
}
|
||||
},
|
||||
validator: (value) {
|
||||
if (value!.trim().isEmpty) {
|
||||
return "Toto pole je povinné!";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
"Oblíbený jazyk:",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
DropdownButton(
|
||||
value: jazyk,
|
||||
dropdownColor: Vzhled.backgroundColor,
|
||||
items: jazyky
|
||||
.map(
|
||||
(e) => DropdownMenuItem(
|
||||
value: e["jazyk"],
|
||||
child: Text(e["jazyk"]),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
jazyk = (value as String?)!;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
OutlinedButton(
|
||||
style: Vzhled.orangeCudlik,
|
||||
onPressed: () async {
|
||||
if (form.currentState!.validate()) {
|
||||
signUp();
|
||||
}
|
||||
},
|
||||
child: const Text("Registrovat se"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text("nebo"),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showSignIn = true;
|
||||
});
|
||||
},
|
||||
child: const Text("Přihlásit se", style: Vzhled.textBtn),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void signIn() {
|
||||
FirebaseAuth.instance
|
||||
.signInWithEmailAndPassword(
|
||||
email: emailCon.text, password: passwordCon.text)
|
||||
.then(
|
||||
(value) => Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (c) => const HlavniOkno()),
|
||||
),
|
||||
)
|
||||
.onError((e, st) {
|
||||
if (e.toString().contains("firebase_auth/user-not-found")) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (c) => const AlertDialog(
|
||||
title: Text("Chyba"),
|
||||
content: Text("Váš účet neexistuje"),
|
||||
),
|
||||
);
|
||||
} else if (e.toString().contains("firebase_auth/wrong-password")) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (c) => const AlertDialog(
|
||||
title: Text("Chyba"),
|
||||
content: Text("Zadáváte špatné heslo!"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (c) => const AlertDialog(
|
||||
title: Text("Chyba"),
|
||||
content: Text("Nastala neznámá chyba."),
|
||||
),
|
||||
);
|
||||
debugPrint(e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void signUp() {
|
||||
FirebaseAuth.instance
|
||||
.createUserWithEmailAndPassword(
|
||||
email: emailCon.text, password: passwordCon.text)
|
||||
.then(
|
||||
(value) async {
|
||||
await FirebaseFirestore.instance
|
||||
.collection("users")
|
||||
.doc(FirebaseAuth.instance.currentUser!.uid)
|
||||
.set({
|
||||
"name": nameCon.text,
|
||||
"email": emailCon.text,
|
||||
"favourite": jazyk,
|
||||
});
|
||||
value.user?.updateDisplayName(nameCon.text);
|
||||
|
||||
if (!mounted) return;
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (c) => const HlavniOkno()),
|
||||
);
|
||||
},
|
||||
).onError((error, stackTrace) {
|
||||
if (error.toString().contains("firebase_auth/email-already-in-use")) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (c) => const AlertDialog(
|
||||
title: Text("Chyba"),
|
||||
content: Text("E-mail je již zaregistrovaný"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (c) => const AlertDialog(
|
||||
title: Text("Chyba"),
|
||||
content: Text("Nastala neznámá chyba."),
|
||||
),
|
||||
);
|
||||
debugPrint(error.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
5
lib/utils/datum.dart
Normal file
5
lib/utils/datum.dart
Normal file
|
@ -0,0 +1,5 @@
|
|||
extension DateString on DateTime {
|
||||
String get dateString => "$day. $month. $year";
|
||||
String get dateTimeString =>
|
||||
"$day. $month. $year $hour:${minute < 10 ? "0$minute" : minute}";
|
||||
}
|
48
lib/utils/devicecontainer.dart
Normal file
48
lib/utils/devicecontainer.dart
Normal file
|
@ -0,0 +1,48 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
|
||||
// Předloha pro widgety, které se mění podle druhu zařízení
|
||||
abstract class DeviceWidget<D extends Widget, M extends Widget>
|
||||
extends StatelessWidget {
|
||||
const DeviceWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (Device.screenType == ScreenType.mobile) {
|
||||
return buildProMobily(context);
|
||||
} else {
|
||||
return buildProDesktop(context);
|
||||
}
|
||||
}
|
||||
|
||||
M buildProMobily(BuildContext context);
|
||||
|
||||
D buildProDesktop(BuildContext context);
|
||||
}
|
||||
|
||||
class DeviceContainer extends DeviceWidget<Row, Column> {
|
||||
final MainAxisAlignment mainAxisAlignmentMobile;
|
||||
final MainAxisAlignment mainAxisAlignmentDesktop;
|
||||
final CrossAxisAlignment crossAxisAlignment;
|
||||
final List<Widget> children;
|
||||
|
||||
/// Vytvoří kontejner, kde na mobilech je [Column] a na ostatních [Row]
|
||||
const DeviceContainer(
|
||||
{super.key,
|
||||
this.children = const [],
|
||||
this.mainAxisAlignmentMobile = MainAxisAlignment.center,
|
||||
this.mainAxisAlignmentDesktop = MainAxisAlignment.start,
|
||||
this.crossAxisAlignment = CrossAxisAlignment.center});
|
||||
|
||||
@override
|
||||
Row buildProDesktop(BuildContext context) => Row(
|
||||
mainAxisAlignment: mainAxisAlignmentDesktop,
|
||||
children: children,
|
||||
);
|
||||
|
||||
@override
|
||||
Column buildProMobily(BuildContext context) => Column(
|
||||
mainAxisAlignment: mainAxisAlignmentMobile,
|
||||
children: children,
|
||||
);
|
||||
}
|
12
lib/utils/dokument.dart
Normal file
12
lib/utils/dokument.dart
Normal file
|
@ -0,0 +1,12 @@
|
|||
import 'package:fleather/fleather.dart';
|
||||
|
||||
extension ActualJson on ParchmentDocument {
|
||||
List<Map<String, dynamic>> toActualJson() {
|
||||
var out = <Map<String, dynamic>>[];
|
||||
var d = toDelta().toList();
|
||||
for (var element in d) {
|
||||
out.add(element.toJson());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
17
lib/utils/input_decoration.dart
Normal file
17
lib/utils/input_decoration.dart
Normal file
|
@ -0,0 +1,17 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
InputDecoration inputDecoration(String text) {
|
||||
return InputDecoration(
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
label: Text(
|
||||
text,
|
||||
),
|
||||
border: UnderlineInputBorder(
|
||||
borderSide: const BorderSide(color: Colors.black, width: 2.0),
|
||||
borderRadius: BorderRadius.circular(6.0)),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: const BorderSide(color: Color(0xffCA1F3D), width: 2.0),
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
);
|
||||
}
|
29
lib/utils/loading_widget.dart
Normal file
29
lib/utils/loading_widget.dart
Normal file
|
@ -0,0 +1,29 @@
|
|||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoadingWidget extends StatelessWidget {
|
||||
const LoadingWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Vzhled.purple,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final jazyky = <Map<String, dynamic>>[
|
||||
{"jazyk": "C#", "barva": 0xff8200f3},
|
||||
{"jazyk": "JavaScript", "barva": 0xfffdd700},
|
||||
{"jazyk": "Python", "barva": 0xff0080ee},
|
||||
{"jazyk": "PHP🤢", "barva": 0xff00abff},
|
||||
{"jazyk": "C++", "barva": 0xff1626ff},
|
||||
{"jazyk": "Kotlin", "barva": 0xffe34b7c},
|
||||
{"jazyk": "Java", "barva": 0xfff58219},
|
||||
{"jazyk": "Dart", "barva": 0xff40c4ff},
|
||||
{"jazyk": "F#", "barva": 0xff85ddf3},
|
||||
{"jazyk": "Elixir", "barva": 0xff543465},
|
||||
{"jazyk": "Carbon", "barva": 0xff606060}
|
||||
];
|
22
lib/utils/months.dart
Normal file
22
lib/utils/months.dart
Normal file
|
@ -0,0 +1,22 @@
|
|||
final months = [
|
||||
Month("Leden", 31, 0),
|
||||
Month("Únor", 28, 1),
|
||||
Month("Březen", 31, 2),
|
||||
Month("Duben", 30, 3),
|
||||
Month("Květen", 31, 4),
|
||||
Month("Červen", 30, 5),
|
||||
Month("Červenec", 31, 6),
|
||||
Month("Srpen", 31, 7),
|
||||
Month("Září", 30, 8),
|
||||
Month("Říjen", 31, 9),
|
||||
Month("Listopad", 30, 10),
|
||||
Month("Prosinec", 31, 11),
|
||||
];
|
||||
|
||||
class Month {
|
||||
String name;
|
||||
int days;
|
||||
int position;
|
||||
|
||||
Month(this.name, this.days, this.position);
|
||||
}
|
6
lib/utils/my_category.dart
Normal file
6
lib/utils/my_category.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
class MyCategory {
|
||||
String name;
|
||||
String id;
|
||||
|
||||
MyCategory(this.name, this.id);
|
||||
}
|
43
lib/utils/my_container.dart
Normal file
43
lib/utils/my_container.dart
Normal file
|
@ -0,0 +1,43 @@
|
|||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
|
||||
class MyContainer extends StatelessWidget {
|
||||
const MyContainer(
|
||||
{required this.child, this.width, this.height, this.padding, super.key});
|
||||
final Widget child;
|
||||
final double? width;
|
||||
final double? height;
|
||||
final double? padding;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: padding == null
|
||||
? const EdgeInsets.only(left: 30, top: 15, right: 30, bottom: 15)
|
||||
: EdgeInsets.all(padding!),
|
||||
width: width ??
|
||||
((Device.screenType == ScreenType.mobile)
|
||||
? Adaptive.w(80)
|
||||
: Adaptive.w(60)),
|
||||
height: height,
|
||||
decoration: const BoxDecoration(
|
||||
color: Vzhled.dialogColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
bottomLeft: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10)),
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: const Color.fromARGB(255, 74, 74, 74).withOpacity(0.25),
|
||||
// spreadRadius: 3,
|
||||
// blurRadius: 5,
|
||||
// offset: const Offset(0, 3),
|
||||
// ),
|
||||
// ],
|
||||
),
|
||||
child: Padding(padding: const EdgeInsets.all(15), child: child),
|
||||
);
|
||||
}
|
||||
}
|
936
lib/utils/new_record_dialog.dart
Normal file
936
lib/utils/new_record_dialog.dart
Normal file
|
@ -0,0 +1,936 @@
|
|||
import 'package:denikprogramatora/okna/app.dart';
|
||||
import 'package:denikprogramatora/utils/datum.dart';
|
||||
import 'package:denikprogramatora/utils/devicecontainer.dart';
|
||||
import 'package:denikprogramatora/utils/dokument.dart';
|
||||
import 'package:denikprogramatora/utils/loading_widget.dart';
|
||||
import 'package:denikprogramatora/utils/programmer.dart';
|
||||
import 'package:denikprogramatora/utils/really_delete.dart';
|
||||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:fleather/fleather.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../utils/my_category.dart';
|
||||
|
||||
Future<void> showCreateItemDialog(context,
|
||||
{DateTime? from,
|
||||
DateTime? to,
|
||||
String? j,
|
||||
int hvezdicky = 0,
|
||||
String? p,
|
||||
List<MyCategory>? k,
|
||||
String? originalId,
|
||||
ParchmentDocument? doc}) async {
|
||||
DateTime fromDate = from ??
|
||||
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day,
|
||||
DateTime.now().hour - 1);
|
||||
DateTime toDate = to ??
|
||||
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day,
|
||||
DateTime.now().hour);
|
||||
|
||||
// nastavení jazyka na oblíbený jazyk
|
||||
String jazyk = "C#";
|
||||
if (j == null) {
|
||||
await ref.get().then((value) {
|
||||
jazyk = value["favourite"];
|
||||
});
|
||||
} else {
|
||||
jazyk = j;
|
||||
}
|
||||
|
||||
int review = hvezdicky;
|
||||
|
||||
Programmer programmer = p == null
|
||||
? Programmer(name, userUid)
|
||||
: await Programmer.ziskatProgramatora(
|
||||
FirebaseAuth.instance.currentUser!, p);
|
||||
|
||||
List<MyCategory> categories = k ?? [];
|
||||
|
||||
FleatherController controller =
|
||||
doc == null ? FleatherController() : FleatherController(doc);
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
scrollable: true,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
title: Text(doc == null ? "Nový záznam" : "Úprava záznamu",
|
||||
style: Vzhled.velkyText),
|
||||
content: StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return Column(
|
||||
children: [
|
||||
DeviceContainer(
|
||||
mainAxisAlignmentDesktop: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(
|
||||
width:
|
||||
(Device.screenType == ScreenType.mobile) ? 80.w : 40.w,
|
||||
child: Column(
|
||||
children: [
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Datum a čas",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Text("Od ${toDate.dateTimeString}"),
|
||||
const SizedBox(width: 15),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate: fromDate,
|
||||
firstDate:
|
||||
DateTime(DateTime.now().year - 5),
|
||||
lastDate:
|
||||
DateTime(DateTime.now().year + 5))
|
||||
.then((value) {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime:
|
||||
TimeOfDay.fromDateTime(fromDate))
|
||||
.then((time) {
|
||||
if (value!.day == toDate.day &&
|
||||
value.month == toDate.month &&
|
||||
value.year == toDate.year &&
|
||||
(time!.hour > toDate.hour ||
|
||||
(time.hour <= toDate.hour &&
|
||||
time.minute > toDate.minute))) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
fromDate = DateTime(
|
||||
value.year,
|
||||
value.month,
|
||||
value.day,
|
||||
time!.hour,
|
||||
time.minute);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Změnit",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Row(
|
||||
children: [
|
||||
Text("Do ${toDate.dateTimeString}"),
|
||||
const SizedBox(width: 15),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate: toDate,
|
||||
firstDate:
|
||||
DateTime(DateTime.now().year - 5),
|
||||
lastDate:
|
||||
DateTime(DateTime.now().year + 5))
|
||||
.then((value) {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime:
|
||||
TimeOfDay.fromDateTime(toDate))
|
||||
.then((time) {
|
||||
if (value!.day == fromDate.day &&
|
||||
value.month == fromDate.month &&
|
||||
value.year == fromDate.year &&
|
||||
(time!.hour < fromDate.hour ||
|
||||
(time.hour >= fromDate.hour &&
|
||||
time.minute <
|
||||
fromDate.minute))) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
toDate = DateTime(value.year, value.month,
|
||||
value.day, time!.hour, time.minute);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
("Změnit"),
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Strávený čas",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"${toDate.difference(fromDate).inHours} ${toDate.difference(fromDate).inHours == 1 ? "hodina" : toDate.difference(fromDate).inHours > 1 && toDate.difference(fromDate).inHours < 5 ? "hodiny" : "hodin"}${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60 == 0) ? "" : " a ${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60)} ${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) == 1 ? "minuta" : (toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) > 1 && (toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) < 5 ? "minuty" : "minut"}"}"),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Programátor",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
await showProgrammersDialog(context, doc: doc)
|
||||
.then((value) {
|
||||
setState(() {
|
||||
programmer = value;
|
||||
});
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
programmer.name,
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
(Device.screenType == ScreenType.mobile) ? 80.w : 40.w,
|
||||
child: Column(
|
||||
children: [
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Programovací jazyk",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: DropdownButton(
|
||||
value: jazyk,
|
||||
dropdownColor: Vzhled.backgroundColor,
|
||||
items: jazyky
|
||||
.map(
|
||||
(e) => DropdownMenuItem(
|
||||
value: e["jazyk"],
|
||||
child: Text(e["jazyk"]),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
jazyk = (value as String?)!;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Hodnocení",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Row(
|
||||
children: List.generate(
|
||||
5,
|
||||
(index) {
|
||||
return IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
review = index + 1;
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.star,
|
||||
color: (index + 1) <= review
|
||||
? Colors.yellow
|
||||
: Colors.grey),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Kategorie",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
List<MyCategory> newCategories =
|
||||
await showCategoriesDialog(
|
||||
context, categories);
|
||||
setState(() {
|
||||
categories = newCategories;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Vybrat",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: List.generate(
|
||||
categories.length,
|
||||
(index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(categories[index].name),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
height: Adaptive.h(35),
|
||||
width: Adaptive.w(100),
|
||||
child: Column(
|
||||
children: [
|
||||
FleatherToolbar.basic(
|
||||
controller: controller, hideHorizontalRule: true),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: FleatherEditor(controller: controller),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
OutlinedButton(
|
||||
style: Vzhled.orangeCudlik,
|
||||
onPressed: () {
|
||||
if (originalId == null) {
|
||||
ref.collection("records").add({
|
||||
"fromDate": fromDate,
|
||||
"toDate": toDate,
|
||||
"codingTime":
|
||||
"${toDate.difference(fromDate).inHours} ${toDate.difference(fromDate).inHours == 1 ? "hodina" : toDate.difference(fromDate).inHours > 1 && toDate.difference(fromDate).inHours < 5 ? "hodiny" : "hodin"}${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60 == 0) ? "" : " a ${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60)} ${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) == 1 ? "minuta" : (toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) > 1 && (toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) < 5 ? "minuty" : "minut"}"}",
|
||||
"programmer": programmer.id,
|
||||
"programmerName": programmer.name,
|
||||
"language": jazyky
|
||||
.where((element) => element["jazyk"] == jazyk)
|
||||
.toList()[0],
|
||||
"review": review,
|
||||
"categories": categories.map((e) => e.id).toList(),
|
||||
"description": controller.document.toActualJson(),
|
||||
}).then((value) =>
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop("dialog"));
|
||||
return;
|
||||
}
|
||||
ref.collection("records").doc(originalId).update({
|
||||
"fromDate": fromDate,
|
||||
"toDate": toDate,
|
||||
"codingTime":
|
||||
"${toDate.difference(fromDate).inHours} ${toDate.difference(fromDate).inHours == 1 ? "hodina" : toDate.difference(fromDate).inHours > 1 && toDate.difference(fromDate).inHours < 5 ? "hodiny" : "hodin"}${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60 == 0) ? "" : " a ${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60)} ${(toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) == 1 ? "minuta" : (toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) > 1 && (toDate.difference(fromDate).inMinutes - toDate.difference(fromDate).inHours * 60) < 5 ? "minuty" : "minut"}"}",
|
||||
"programmer": programmer.id,
|
||||
"programmerName": programmer.name,
|
||||
"language": jazyky
|
||||
.where((element) => element["jazyk"] == jazyk)
|
||||
.toList()[0],
|
||||
"review": review,
|
||||
"categories": categories.map((e) => e.id).toList(),
|
||||
"description": controller.document.toActualJson(),
|
||||
}).then((value) =>
|
||||
Navigator.of(context, rootNavigator: true).pop("dialog"));
|
||||
},
|
||||
child: Text(
|
||||
(originalId == null) ? "Vytvořit" : "Změnit",
|
||||
style: const TextStyle(
|
||||
fontSize: Vzhled.text,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<Programmer> showProgrammersDialog(context,
|
||||
{ParchmentDocument? doc, bool jenMenit = false}) async {
|
||||
bool showAddProgrammer = false;
|
||||
bool editing = false;
|
||||
GlobalKey<FormState> key = GlobalKey<FormState>();
|
||||
TextEditingController nameCon = TextEditingController();
|
||||
late String editId;
|
||||
|
||||
Programmer programmer = Programmer(name, userUid);
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text("Programátoři", style: Vzhled.velkyText),
|
||||
scrollable: true,
|
||||
content: SizedBox(
|
||||
width: 50.w,
|
||||
child: StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return showAddProgrammer
|
||||
? Form(
|
||||
key: key,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: nameCon,
|
||||
decoration: Vzhled.inputDecoration("Jméno"),
|
||||
validator: (value) {
|
||||
if (value!.trim().isEmpty) {
|
||||
return "Toto pole je povinné!";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (key.currentState!.validate()) {
|
||||
if (editing) {
|
||||
ref
|
||||
.collection("programmers")
|
||||
.doc(editId)
|
||||
.update({"name": nameCon.text});
|
||||
} else {
|
||||
var uuid = const Uuid();
|
||||
String id = uuid.v1();
|
||||
|
||||
ref
|
||||
.collection("programmers")
|
||||
.doc(id)
|
||||
.set({"name": nameCon.text, "id": id});
|
||||
}
|
||||
nameCon.text = "";
|
||||
|
||||
setState(() {
|
||||
editing = false;
|
||||
showAddProgrammer = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
editing ? "Uložit" : "Přidat",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showAddProgrammer = false;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Zpátky",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Material(
|
||||
color: Vzhled.dialogColor,
|
||||
child: InkWell(
|
||||
splashColor: (jenMenit) ? Colors.transparent : null,
|
||||
onTap: () {
|
||||
if (jenMenit) return;
|
||||
programmer = Programmer(name, userUid);
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop("dialog");
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(name),
|
||||
if (!jenMenit)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
programmer = Programmer(name, userUid);
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop("dialog");
|
||||
},
|
||||
child: const Text(
|
||||
"Vybrat",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
StreamBuilder(
|
||||
stream: ref.collection("programmers").snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
var docs = snapshot.data!.docs;
|
||||
|
||||
return Column(
|
||||
children: List.generate(docs.length, (index) {
|
||||
var data = docs[index].data();
|
||||
return Material(
|
||||
color: Vzhled.dialogColor,
|
||||
child: InkWell(
|
||||
splashColor: (jenMenit)
|
||||
? Colors.transparent
|
||||
: null,
|
||||
onTap: () {
|
||||
if (jenMenit) return;
|
||||
programmer = Programmer(
|
||||
data["name"], data["id"]);
|
||||
Navigator.of(context,
|
||||
rootNavigator: true)
|
||||
.pop("dialog");
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(data["name"]),
|
||||
Row(
|
||||
children: [
|
||||
if (!jenMenit)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
programmer = Programmer(
|
||||
data["name"],
|
||||
data["id"]);
|
||||
Navigator.of(context,
|
||||
rootNavigator:
|
||||
true)
|
||||
.pop("dialog");
|
||||
},
|
||||
child: const Text(
|
||||
"Vybrat",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
editId = data["id"];
|
||||
|
||||
setState(() {
|
||||
showAddProgrammer = true;
|
||||
editing = true;
|
||||
nameCon =
|
||||
TextEditingController(
|
||||
text:
|
||||
data["name"]);
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.edit,
|
||||
color: Vzhled.textColor),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showReallyDelete(context,
|
||||
() async {
|
||||
Navigator.of(context,
|
||||
rootNavigator:
|
||||
true)
|
||||
.pop("dialog");
|
||||
Navigator.of(context,
|
||||
rootNavigator:
|
||||
true)
|
||||
.pop("dialog");
|
||||
if (doc != null) {
|
||||
Navigator.of(context,
|
||||
rootNavigator:
|
||||
true)
|
||||
.pop("dialog");
|
||||
}
|
||||
|
||||
// deleting all records
|
||||
await ref
|
||||
.collection("records")
|
||||
.where("programmer",
|
||||
isEqualTo:
|
||||
data["id"])
|
||||
.get()
|
||||
.then((value) {
|
||||
for (var snap
|
||||
in value.docs) {
|
||||
ref
|
||||
.collection(
|
||||
"records")
|
||||
.doc(snap.id)
|
||||
.delete();
|
||||
}
|
||||
});
|
||||
|
||||
// deleting
|
||||
await ref
|
||||
.collection(
|
||||
"programmers")
|
||||
.doc(data["id"])
|
||||
.delete();
|
||||
},
|
||||
doNavigatorPop: false,
|
||||
text:
|
||||
"Odstranit programátora a všechny jeho záznamy?");
|
||||
},
|
||||
icon: const Icon(Icons.delete,
|
||||
color: Vzhled.textColor),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const LoadingWidget();
|
||||
}),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showAddProgrammer = true;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Přidat nového programátora",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return programmer;
|
||||
}
|
||||
|
||||
Future<List<MyCategory>> showCategoriesDialog(
|
||||
context, List<MyCategory> categories,
|
||||
{bool jenMenit = false}) async {
|
||||
bool showCategoryEdit = false;
|
||||
bool editing = false;
|
||||
GlobalKey<FormState> key = GlobalKey<FormState>();
|
||||
TextEditingController nameCon = TextEditingController();
|
||||
int color = 0;
|
||||
String editId = "";
|
||||
|
||||
Map selected = {};
|
||||
|
||||
// fetching data for all categories and setting selected to false
|
||||
await ref.collection("categories").get().then((value) {
|
||||
for (var snap in value.docs) {
|
||||
selected[snap.id] = false;
|
||||
}
|
||||
});
|
||||
|
||||
// already selected categories setting to true
|
||||
for (var snap in categories) {
|
||||
selected[snap.id] = true;
|
||||
}
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text("Kategorie", style: Vzhled.velkyText),
|
||||
scrollable: true,
|
||||
content: SizedBox(
|
||||
width: 50.w,
|
||||
child: StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return showCategoryEdit
|
||||
? Form(
|
||||
key: key,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: nameCon,
|
||||
decoration: Vzhled.inputDecoration("Název"),
|
||||
validator: (value) {
|
||||
if (value!.trim().isEmpty) {
|
||||
return "Toto pole je povinné!";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (key.currentState!.validate()) {
|
||||
if (editing) {
|
||||
ref
|
||||
.collection("categories")
|
||||
.doc(editId)
|
||||
.update({
|
||||
"name": nameCon.text,
|
||||
"color": color,
|
||||
});
|
||||
} else {
|
||||
var uuid = const Uuid();
|
||||
String id = uuid.v1();
|
||||
|
||||
ref.collection("categories").doc(id).set({
|
||||
"name": nameCon.text,
|
||||
"id": id,
|
||||
"color": color
|
||||
});
|
||||
|
||||
selected[id] = false;
|
||||
}
|
||||
|
||||
nameCon.text = "";
|
||||
|
||||
setState(() {
|
||||
showCategoryEdit = false;
|
||||
editing = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
editing ? "Uložit" : "Přidat",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showCategoryEdit = false;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Zpátky",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
StreamBuilder(
|
||||
stream: ref.collection("categories").snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
var docs = snapshot.data!.docs;
|
||||
|
||||
return Column(
|
||||
children: List.generate(docs.length, (index) {
|
||||
var data = docs[index].data();
|
||||
|
||||
return Material(
|
||||
color: Vzhled.dialogColor,
|
||||
child: InkWell(
|
||||
splashColor: (jenMenit)
|
||||
? Colors.transparent
|
||||
: null,
|
||||
onTap: (() {
|
||||
if (jenMenit) return;
|
||||
setState(
|
||||
() {
|
||||
selected[data["id"]] =
|
||||
!selected[data["id"]];
|
||||
},
|
||||
);
|
||||
}),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(data["name"]),
|
||||
(selected[data["id"]])
|
||||
? TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
selected[data["id"]] =
|
||||
false;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Odebrat",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
if (!jenMenit)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
selected[data[
|
||||
"id"]] = true;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Vybrat",
|
||||
style:
|
||||
Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
editId = data["id"];
|
||||
|
||||
setState(() {
|
||||
showCategoryEdit =
|
||||
true;
|
||||
editing = true;
|
||||
nameCon =
|
||||
TextEditingController(
|
||||
text: data[
|
||||
"name"]);
|
||||
});
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.edit,
|
||||
color: Vzhled
|
||||
.textColor,
|
||||
size: 18),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showReallyDelete(
|
||||
context, () {
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator:
|
||||
true)
|
||||
.pop("dialog");
|
||||
|
||||
ref
|
||||
.collection(
|
||||
"categories")
|
||||
.doc(data["id"])
|
||||
.delete();
|
||||
},
|
||||
doNavigatorPop:
|
||||
false);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.delete,
|
||||
color: Vzhled
|
||||
.textColor,
|
||||
size: 18),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const LoadingWidget();
|
||||
}),
|
||||
const SizedBox(height: 5),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
showCategoryEdit = true;
|
||||
});
|
||||
},
|
||||
child: const Text(
|
||||
"Nová kategorie",
|
||||
style: Vzhled.textBtn,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// creating new list
|
||||
categories = [];
|
||||
await ref.collection("categories").get().then(
|
||||
(value) {
|
||||
var docs = value.docs;
|
||||
for (var snap in docs) {
|
||||
if (selected[snap.id]) {
|
||||
var data = snap.data();
|
||||
categories.add(MyCategory(data["name"], snap.id));
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// popravde som prave napisal totalne shitny kod, ale nemam najmensiu chybu hladata lepsie riesenie. ak toto citas kludne to cele prepis a odstran
|
||||
|
||||
return categories;
|
||||
}
|
23
lib/utils/programmer.dart
Normal file
23
lib/utils/programmer.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
|
||||
class Programmer {
|
||||
final String name;
|
||||
final String id;
|
||||
|
||||
const Programmer(this.name, this.id);
|
||||
|
||||
static Future<Programmer> ziskatProgramatora(User current, String id) async {
|
||||
if (id == current.uid) {
|
||||
return Programmer(current.displayName!, id);
|
||||
} else {
|
||||
var d = await FirebaseFirestore.instance
|
||||
.collection("users")
|
||||
.doc(current.uid)
|
||||
.collection("programmers")
|
||||
.doc(id)
|
||||
.get();
|
||||
return Programmer(d.data()!["name"], id);
|
||||
}
|
||||
}
|
||||
}
|
38
lib/utils/razeni.dart
Normal file
38
lib/utils/razeni.dart
Normal file
|
@ -0,0 +1,38 @@
|
|||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
var razeni = [
|
||||
// VZESTUPNĚ ČAS
|
||||
(QueryDocumentSnapshot<Map<String, dynamic>> a,
|
||||
QueryDocumentSnapshot<Map<String, dynamic>> b) =>
|
||||
((a.data()["fromDate"] as Timestamp).toDate().hour ==
|
||||
(b.data()["fromDate"] as Timestamp).toDate().hour)
|
||||
? (a.data()["fromDate"] as Timestamp)
|
||||
.toDate()
|
||||
.minute
|
||||
.compareTo((b.data()["fromDate"] as Timestamp).toDate().minute)
|
||||
: (a.data()["fromDate"] as Timestamp)
|
||||
.toDate()
|
||||
.hour
|
||||
.compareTo((b.data()["fromDate"] as Timestamp).toDate().hour),
|
||||
// SESTUPNĚ ČAS
|
||||
(QueryDocumentSnapshot<Map<String, dynamic>> a,
|
||||
QueryDocumentSnapshot<Map<String, dynamic>> b) =>
|
||||
((b.data()["fromDate"] as Timestamp).toDate().hour ==
|
||||
(a.data()["fromDate"] as Timestamp).toDate().hour)
|
||||
? (b.data()["fromDate"] as Timestamp)
|
||||
.toDate()
|
||||
.minute
|
||||
.compareTo((a.data()["fromDate"] as Timestamp).toDate().minute)
|
||||
: (b.data()["fromDate"] as Timestamp)
|
||||
.toDate()
|
||||
.hour
|
||||
.compareTo((a.data()["fromDate"] as Timestamp).toDate().hour),
|
||||
// VZESTUPNĚ HODNOCENÍ
|
||||
(QueryDocumentSnapshot<Map<String, dynamic>> a,
|
||||
QueryDocumentSnapshot<Map<String, dynamic>> b) =>
|
||||
(a.data()["review"] as int).compareTo(b.data()["review"]),
|
||||
// SESTUPNĚ HODNOCENÍ
|
||||
(QueryDocumentSnapshot<Map<String, dynamic>> a,
|
||||
QueryDocumentSnapshot<Map<String, dynamic>> b) =>
|
||||
(b.data()["review"] as int).compareTo(a.data()["review"]),
|
||||
];
|
24
lib/utils/really_delete.dart
Normal file
24
lib/utils/really_delete.dart
Normal file
|
@ -0,0 +1,24 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
showReallyDelete(BuildContext context, void Function() onPressed,
|
||||
{text = "Odstranit tuto položku?", bool doNavigatorPop = true}) async {
|
||||
if (doNavigatorPop) Navigator.of(context, rootNavigator: true).pop("dialog");
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(text),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(ctx, rootNavigator: true).pop("dialog"),
|
||||
child:
|
||||
const Text("Ne", style: TextStyle(color: Colors.blue))),
|
||||
TextButton(onPressed: onPressed, child: const Text("Ano"))
|
||||
],
|
||||
));
|
||||
}
|
230
lib/utils/show_info_dialog.dart
Normal file
230
lib/utils/show_info_dialog.dart
Normal file
|
@ -0,0 +1,230 @@
|
|||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:denikprogramatora/okna/app.dart';
|
||||
import 'package:denikprogramatora/utils/datum.dart';
|
||||
import 'package:denikprogramatora/utils/devicecontainer.dart';
|
||||
import 'package:denikprogramatora/utils/my_category.dart';
|
||||
import 'package:denikprogramatora/utils/new_record_dialog.dart';
|
||||
import 'package:denikprogramatora/utils/really_delete.dart';
|
||||
import 'package:denikprogramatora/utils/vzhled.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:fleather/fleather.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:responsive_sizer/responsive_sizer.dart';
|
||||
|
||||
void showInfoDialog(
|
||||
context, Map<String, dynamic> data, String originalId) async {
|
||||
var denOd = (data["fromDate"] as Timestamp).toDate().toLocal();
|
||||
var denDo = (data["toDate"] as Timestamp).toDate().toLocal();
|
||||
List<MyCategory> categories = [];
|
||||
|
||||
if ((data["categories"] as List).isNotEmpty) {
|
||||
for (var category in data["categories"]) {
|
||||
await ref.collection("categories").doc(category).get().then((value) {
|
||||
var data = value.data();
|
||||
|
||||
categories.add(MyCategory(data!["name"], category));
|
||||
}).onError((error, stackTrace) => null);
|
||||
}
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
var document = ParchmentDocument.fromJson(data["description"]);
|
||||
var controller = FleatherController(document);
|
||||
|
||||
return AlertDialog(
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => showReallyDelete(
|
||||
context,
|
||||
() => FirebaseFirestore.instance
|
||||
.collection("users")
|
||||
.doc(FirebaseAuth.instance.currentUser!.uid)
|
||||
.collection("records")
|
||||
.doc(originalId)
|
||||
.delete()
|
||||
.then((_) => Navigator.of(context).pop())),
|
||||
style: Vzhled.orangeCudlik,
|
||||
child: const Text("Smazat")),
|
||||
TextButton(
|
||||
style: Vzhled.purpleCudlik,
|
||||
onPressed: () {
|
||||
showCreateItemDialog(context,
|
||||
from: denOd,
|
||||
to: denDo,
|
||||
k: categories,
|
||||
p: data["programmer"],
|
||||
hvezdicky: data["review"],
|
||||
originalId: originalId,
|
||||
j: data["language"]["jazyk"],
|
||||
doc: document)
|
||||
.then((_) => Navigator.of(context).pop());
|
||||
},
|
||||
child: const Text("Upravit")),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
style: Vzhled.purpleCudlik,
|
||||
child: const Text("Zavřít"),
|
||||
),
|
||||
],
|
||||
title: Text(
|
||||
"Záznam ze dne ${denOd.dateString}",
|
||||
style: Vzhled.dialogNadpis,
|
||||
),
|
||||
scrollable: true,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
content: SizedBox(
|
||||
height: 60.h,
|
||||
width: 90.w,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
DeviceContainer(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 80.w
|
||||
: 40.w,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Datum: ",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
Text(
|
||||
(Device.screenType == ScreenType.mobile)
|
||||
? "od ${denOd.dateTimeString}\ndo ${denDo.dateTimeString} (${data["codingTime"]})"
|
||||
: "od ${denOd.dateTimeString} do ${denDo.dateTimeString} (${data["codingTime"]})",
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Jazyk: ",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
Text(
|
||||
data["language"]["jazyk"],
|
||||
style: TextStyle(
|
||||
color: Color(data["language"]["barva"])),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: (Device.screenType == ScreenType.mobile)
|
||||
? 80.w
|
||||
: 40.w,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Programátor: ",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
Text(
|
||||
data["programmerName"],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Hodnocení: ",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
Row(
|
||||
children: List.generate(
|
||||
5,
|
||||
(index) {
|
||||
return Icon(Icons.star,
|
||||
color: (index + 1) <= data["review"]
|
||||
? Colors.yellow
|
||||
: Colors.grey);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
if (categories.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Kategorie",
|
||||
style: Vzhled.nadpis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: List.generate(
|
||||
categories.length,
|
||||
(index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(categories[index].name),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: Adaptive.h(35),
|
||||
width: Adaptive.w(100),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: FleatherEditor(
|
||||
readOnly: true, controller: controller),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
64
lib/utils/vzhled.dart
Normal file
64
lib/utils/vzhled.dart
Normal file
|
@ -0,0 +1,64 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class Vzhled {
|
||||
static const purple = Color.fromARGB(255, 105, 108, 180);
|
||||
static const textColor = Color(0xfff1f1f3);
|
||||
static const orange = Color(0xffff8200); //f58f29);
|
||||
static const backgroundColor = Color(0xff17161b);
|
||||
static const dialogColor = Color(0xff28272c);
|
||||
|
||||
/// Normální tučný velký nadpis
|
||||
static const TextStyle nadpis =
|
||||
TextStyle(fontSize: 20, fontWeight: FontWeight.w700, color: textColor);
|
||||
|
||||
/// Styl nadpisu v dialogu
|
||||
static const TextStyle dialogNadpis =
|
||||
TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: textColor);
|
||||
|
||||
/// Text o velikosti nadpisu, ale normální tloušťka
|
||||
static const TextStyle velkyText = TextStyle(fontSize: 22, color: textColor);
|
||||
|
||||
static const double text = 14;
|
||||
|
||||
/// Větší text, ale ne tučný
|
||||
static const TextStyle mensiAleVelkyText =
|
||||
TextStyle(fontSize: 16, color: textColor);
|
||||
|
||||
static final ButtonStyle purpleCudlik = OutlinedButton.styleFrom(
|
||||
backgroundColor: purple,
|
||||
foregroundColor: textColor,
|
||||
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 20, right: 20),
|
||||
textStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
);
|
||||
|
||||
static final ButtonStyle orangeCudlik = OutlinedButton.styleFrom(
|
||||
backgroundColor: orange,
|
||||
foregroundColor: Colors.black,
|
||||
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 20, right: 20),
|
||||
textStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
);
|
||||
|
||||
static const TextStyle textBtn = TextStyle(
|
||||
color: Vzhled.purple,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
);
|
||||
|
||||
static InputDecoration inputDecoration(String text) {
|
||||
return InputDecoration(
|
||||
labelStyle: const TextStyle(color: Vzhled.textColor),
|
||||
label: Text(
|
||||
text,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(
|
||||
color: Color.fromARGB(255, 173, 173, 173), width: 2.0),
|
||||
borderRadius: BorderRadius.circular(6.0),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Vzhled.purple, width: 2.0),
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue