RADOM JAZDA

This commit is contained in:
doman 2023-07-29 19:21:02 +02:00
parent 0bf689e4ab
commit 99fc05ce72
7 changed files with 157 additions and 9 deletions

10
lib/models/diary.dart Normal file
View file

@ -0,0 +1,10 @@
import 'package:fooder_web/models/meal.dart';
class Diary {
final List<Meal> meals;
const Diary({
required this.meals,
});
}

16
lib/models/entry.dart Normal file
View file

@ -0,0 +1,16 @@
class Entry {
final String name;
final double calories;
final double protein;
final double fat;
final double carb;
const Entry({
required this.name,
required this.calories,
required this.protein,
required this.fat,
required this.carb,
});
}

10
lib/models/meal.dart Normal file
View file

@ -0,0 +1,10 @@
import 'package:fooder_web/models/entry.dart';
class Meal {
final List<Entry> entries;
const Meal({
required this.entries,
});
}

View file

@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:fooder_web/screens/based.dart';
import 'package:fooder_web/screens/login.dart'; import 'package:fooder_web/screens/login.dart';
import 'package:fooder_web/client.dart'; import 'package:fooder_web/client.dart';
import 'package:fooder_web/models/meal.dart';
import 'package:fooder_web/models/entry.dart';
import 'package:fooder_web/models/diary.dart';
import 'package:fooder_web/widgets/diary.dart';
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({super.key});
@ -49,6 +53,47 @@ class _MyHomePageState extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var testDiary = Diary(
meals: <Meal>[
Meal(
entries: <Entry>[
Entry(
name: "DUPA",
calories: 123.21,
protein: 20.13,
fat: 99.99,
carb: -15.02,
),
Entry(
name: "SRAKA",
calories: 123.21,
protein: 20.13,
fat: 99.99,
carb: -15.02,
),
]
),
Meal(
entries: <Entry>[
Entry(
name: "MADA",
calories: 123.21,
protein: 20.13,
fat: 99.99,
carb: -15.02,
),
Entry(
name: "FAKA",
calories: 123.21,
protein: 20.13,
fat: 99.99,
carb: -15.02,
),
]
),
]
);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary, backgroundColor: Theme.of(context).colorScheme.inversePrimary,
@ -58,15 +103,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Container( child: Container(
constraints: const BoxConstraints(maxWidth: 600), constraints: const BoxConstraints(maxWidth: 600),
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: Column( child: DiaryWidget(diary: testDiary),
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FilledButton(
onPressed: _login,
child: const Text('Login'),
)
],
),
), ),
), ),
); );

View file

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:fooder_web/models/diary.dart';
import 'package:fooder_web/widgets/meal.dart';
import 'dart:core';
class DiaryWidget extends StatelessWidget {
final Diary diary;
const DiaryWidget({super.key, required this.diary});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(8),
child: ListView(
padding: const EdgeInsets.all(8),
children: <Widget>[
for (var meal in diary.meals)
MealWidget(
meal: meal,
),
],
),
);
}
}

View file

@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import 'package:fooder_web/models/entry.dart';
import 'dart:core';
class EntryWidget extends StatelessWidget {
final Entry entry;
const EntryWidget({super.key, required this.entry});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(8),
child: Text(entry.name),
);
}
}

View file

@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:fooder_web/models/meal.dart';
import 'package:fooder_web/widgets/entry.dart';
import 'dart:core';
class MealWidget extends StatelessWidget {
final Meal meal;
const MealWidget({super.key, required this.meal});
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.only(
top: 36.0, left: 6.0, right: 6.0, bottom: 6.0),
child: ExpansionTile(
title: const Text('SEKS Z KOBIETA'),
children: <Widget>[
for (var entry in meal.entries)
EntryWidget(
entry: entry,
),
],
),
),
);
}
}