RADOM JAZDA
This commit is contained in:
parent
0bf689e4ab
commit
99fc05ce72
7 changed files with 157 additions and 9 deletions
10
lib/models/diary.dart
Normal file
10
lib/models/diary.dart
Normal 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
16
lib/models/entry.dart
Normal 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
10
lib/models/meal.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
import 'package:fooder_web/models/entry.dart';
|
||||
|
||||
|
||||
class Meal {
|
||||
final List<Entry> entries;
|
||||
|
||||
const Meal({
|
||||
required this.entries,
|
||||
});
|
||||
}
|
|
@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
|
|||
import 'package:fooder_web/screens/based.dart';
|
||||
import 'package:fooder_web/screens/login.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 {
|
||||
const MyApp({super.key});
|
||||
|
@ -49,6 +53,47 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
|
||||
@override
|
||||
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(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
|
@ -58,15 +103,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
FilledButton(
|
||||
onPressed: _login,
|
||||
child: const Text('Login'),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: DiaryWidget(diary: testDiary),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue