Bilder, Anzeigen der Kärtchen, usw hinzugefügt

welcome
Bogdan Kotikov 2023-04-29 15:56:04 +02:00
parent ff74c58163
commit 8697d749c8
28 changed files with 103041 additions and 279 deletions

View File

@ -1,6 +1,12 @@
{ {
"configVersion": 2, "configVersion": 2,
"packages": [ "packages": [
{
"name": "animate_gradient",
"rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/animate_gradient-0.0.2",
"packageUri": "lib/",
"languageVersion": "2.16"
},
{ {
"name": "async", "name": "async",
"rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/async-2.10.0", "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/async-2.10.0",
@ -103,6 +109,12 @@
"packageUri": "lib/", "packageUri": "lib/",
"languageVersion": "2.12" "languageVersion": "2.12"
}, },
{
"name": "percent_indicator",
"rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/percent_indicator-4.2.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{ {
"name": "sky_engine", "name": "sky_engine",
"rootUri": "file:///Users/bogdan/fvm/versions/3.7.9/bin/cache/pkg/sky_engine", "rootUri": "file:///Users/bogdan/fvm/versions/3.7.9/bin/cache/pkg/sky_engine",
@ -158,7 +170,7 @@
"languageVersion": "2.19" "languageVersion": "2.19"
} }
], ],
"generated": "2023-04-19T19:12:52.160361Z", "generated": "2023-04-28T17:54:39.346507Z",
"generator": "pub", "generator": "pub",
"generatorVersion": "2.19.6" "generatorVersion": "2.19.6"
} }

View File

@ -1,3 +1,7 @@
animate_gradient
2.16
file:///Users/bogdan/.pub-cache/hosted/pub.dev/animate_gradient-0.0.2/
file:///Users/bogdan/.pub-cache/hosted/pub.dev/animate_gradient-0.0.2/lib/
async async
2.18 2.18
file:///Users/bogdan/.pub-cache/hosted/pub.dev/async-2.10.0/ file:///Users/bogdan/.pub-cache/hosted/pub.dev/async-2.10.0/
@ -58,6 +62,10 @@ path
2.12 2.12
file:///Users/bogdan/.pub-cache/hosted/pub.dev/path-1.8.2/ file:///Users/bogdan/.pub-cache/hosted/pub.dev/path-1.8.2/
file:///Users/bogdan/.pub-cache/hosted/pub.dev/path-1.8.2/lib/ file:///Users/bogdan/.pub-cache/hosted/pub.dev/path-1.8.2/lib/
percent_indicator
2.12
file:///Users/bogdan/.pub-cache/hosted/pub.dev/percent_indicator-4.2.3/
file:///Users/bogdan/.pub-cache/hosted/pub.dev/percent_indicator-4.2.3/lib/
source_span source_span
2.14 2.14
file:///Users/bogdan/.pub-cache/hosted/pub.dev/source_span-1.9.1/ file:///Users/bogdan/.pub-cache/hosted/pub.dev/source_span-1.9.1/

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,23 +0,0 @@
import 'package:flutter/material.dart';
class CardComponent extends StatelessWidget {
const CardComponent({super.key});
@override
Widget build(BuildContext context) {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.8,
child: Card(
margin: const EdgeInsets.all(20.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
),
),
),
);
}
}

View File

@ -0,0 +1,90 @@
import 'dart:convert';
import 'package:ernaehrung/models/food.dart';
import 'package:flutter/services.dart' as root_bundle;
import 'package:flutter/material.dart';
import '../models/card.dart';
class CardComponent extends StatefulWidget {
final Image image;
final String cardName;
final int? caloriesSummary;
final List<CardModel> listOfCardItems;
const CardComponent(this.image, this.cardName, this.caloriesSummary, this.listOfCardItems, {super.key});
@override
State<CardComponent> createState() => _CardComponentState();
}
class _CardComponentState extends State<CardComponent> {
Future<List<Food>> readJson() async {
final jsonData =
await root_bundle.rootBundle.loadString('assets/json/csvjson_full.json');
final list = json.decode(jsonData) as List<dynamic>;
return list.map((e) => Food.fromJson(e)).toList();
}
String getSummaryOfAllNames(List<CardModel> cardModels){
String names = "";
for (var element in cardModels) {
names += element.getName;
}
return names;
}
Widget _getCalorieContainer(){
if (widget.caloriesSummary != null){
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 0
),
child: Center(
child: Column(
children: [
const Divider(
thickness: 1,
),
Text(widget.caloriesSummary.toString())
],
),
),
);
}else {
return const Placeholder();
}
}
@override
Widget build(BuildContext context) {
return Card(
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
widget.image,
Column(
children: [
Text(widget.cardName),
Text(getSummaryOfAllNames(widget.listOfCardItems))
],
),
ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
shape: const CircleBorder(),
padding: const EdgeInsets.all(8),
),
child: const Text('+', style: TextStyle(fontSize: 28),),
)
],
),
_getCalorieContainer()
],
)
);
}
}

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
class CardItemComponent extends StatelessWidget {
final String title;
final int calories;
const CardItemComponent(Image? image, this.title, this.calories, {super.key});
@override
Widget build(BuildContext context) {
return Column();
}
}

View File

@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
class DietChatComponent extends StatefulWidget {
late int calorienSummary;
final double fatPercentPerThousandCalorie = 3.7;
final double proteinPercentPerThousandCalorie = 4.5;
final double carbsPercentPerThousandCalorie = 12.8;
final String carbs = "Kohlenhydrate";
final String protein = "Protein";
final String fat = "Fett";
late String fatGramm, carbGramm, proteinGramm;
late double fatSummary, carbSummary, proteinSummary;
DietChatComponent(this.calorienSummary, {super.key, int calorienLeft = 0}){
fatSummary = (calorienSummary / 100) * fatPercentPerThousandCalorie;
carbSummary = (calorienSummary / 100) * carbsPercentPerThousandCalorie;
proteinSummary = (calorienSummary / 100) * proteinPercentPerThousandCalorie;
fatGramm = '0 / $fatSummary g';
carbGramm = '0 / $carbSummary g';
proteinGramm = '0 / $proteinSummary g';
}
@override
State<DietChatComponent> createState() => _DietChatComponentState();
}
class _DietChatComponentState extends State<DietChatComponent> {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(widget.carbs),
LinearPercentIndicator(
width: 100.0,
lineHeight: 8.0,
percent: 0.9,
progressColor: Colors.blue,
),
Text(widget.carbGramm)
],
),
Column(
children: [
Text(widget.protein),
LinearPercentIndicator(
width: 100.0,
lineHeight: 8.0,
percent: 0.9,
progressColor: Colors.blue,
),
Text(widget.proteinGramm)
],
),
Column(
children: [
Text(widget.fat),
LinearPercentIndicator(
width: 100.0,
lineHeight: 8.0,
percent: 0.9,
progressColor: Colors.blue,
),
Text(widget.fatGramm)
],
)
],
);
}
}

View File

@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
class StatisticsPercentComponent extends StatelessWidget {
late String eaten, calorienBurned, calorienLeft, calorienLeftPercent;
StatisticsPercentComponent(int eaten, int calorienBurned, int calorienLeft, {super.key}){
this.eaten = '$eaten Gegessen';
this.calorienBurned = '$calorienBurned Verbrannt';
this.calorienLeft = '$calorienLeft Kcal Übrig';
}
String get getEaten => eaten;
get getCalorienBurned => calorienBurned;
get getCalorienLeft => calorienLeft;
get getCalorienLeftPercent => calorienLeftPercent;
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(eaten),
CircularPercentIndicator(
radius: 60.0,
lineWidth: 5.0,
percent: 0.5,
center: const Text("100%"), //TODO: anpassen
progressColor: Colors.lightGreen,
),
Text(calorienBurned),
],
);
}
}

View File

@ -1,4 +1,4 @@
import 'package:ernaehrung/views/navigation/navigationScreen.dart'; import 'package:ernaehrung/views/navigation/navigation_screen.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class WelcomePageStateTextFieldState extends StatefulWidget { class WelcomePageStateTextFieldState extends StatefulWidget {

View File

@ -1,6 +1,5 @@
import 'package:ernaehrung/pages/nav_pages/main_page.dart'; import 'package:ernaehrung/pages/nav_pages/main_page.dart';
import 'package:ernaehrung/views/navigation/navigationScreen.dart'; import 'package:ernaehrung/views/navigation/navigation_screen.dart';
import 'package:ernaehrung/views/welcome/welcomeScreen.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
void main() { void main() {

20
lib/mockdata.dart 100644
View File

@ -0,0 +1,20 @@
import 'package:flutter/cupertino.dart';
import 'models/card.dart';
List<CardModel> essen = [
CardModel('Haferflocken', 10, 1.1, 1.2),
CardModel('Kekse', 20, 2.2, 2.3),
CardModel('Bier', 30, 3.3, 3.4),
];
Map<Map<Image, String>, List<CardModel>> cards = <Map<Image, String>, List<CardModel>>{
{
const Image(image: AssetImage('assets/images/fries.png')): 'Frühstück'
}: essen,
{
const Image(image: AssetImage('assets/images/ice.png')): 'Mittagessen'
}: essen,
{
const Image(image: AssetImage('assets/images/tea.png')): 'Abendessen'
}: essen
};

View File

@ -0,0 +1,14 @@
class CardModel{
final String _name;
final int _calories;
final double _fat;
final double _protein;
CardModel(this._name, this._calories, this._fat, this._protein);
String get getName => _name;
int get getCalories => _calories;
double get getFat => _fat;
double get getProtein => _protein;
}

View File

@ -0,0 +1,9 @@
import 'dart:ui';
class CardItem{
Image image;
String title, description;
int caloriesSummary;
CardItem(this.image, this.title, this.description, this.caloriesSummary);
}

View File

@ -0,0 +1,40 @@
class Food {
Food(this._id, this._name, this._foodGroup, this._calories, this._fatg,
this._proteing, this._carbohydrateg, this._sugarsg, this._fiberg);
Food.fromJson(dynamic json) {
_id = json['ID'];
_name = json['name'];
_foodGroup = json['Food Group'];
_calories = json['Calories'];
_fatg = json['Fat (g)'];
_proteing = json['Protein (g)'];
_carbohydrateg = json['Carbohydrate (g)'];
_sugarsg = json['Sugars (g)'];
_fiberg = json['Fiber (g)'];
}
late int _id;
late String _name;
late String _foodGroup;
late int _calories;
late double _fatg;
late double _proteing;
late double _carbohydrateg;
late double _sugarsg;
late double _fiberg;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['ID'] = _id;
map['name'] = _name;
map['Food Group'] = _foodGroup;
map['Calories'] = _calories;
map['Fat (g)'] = _fatg;
map['Protein (g)'] = _proteing;
map['Carbohydrate (g)'] = _carbohydrateg;
map['Sugars (g)'] = _sugarsg;
map['Fiber (g)'] = _fiberg;
return map;
}
}

View File

View File

@ -8,10 +8,10 @@ class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key); const MainPage({Key? key}) : super(key: key);
@override @override
_MainPageState createState() => _MainPageState(); MainPageState createState() => MainPageState();
} }
class _MainPageState extends State<MainPage> { class MainPageState extends State<MainPage> {
List pages = [ List pages = [
const TodayPage(title: 'Today',), const TodayPage(title: 'Today',),
const MealPlanPage(title: 'Meal Plan'), const MealPlanPage(title: 'Meal Plan'),
@ -22,16 +22,30 @@ class _MainPageState extends State<MainPage> {
void onTap(int index){ void onTap(int index){
setState(() { setState(() {
currentIndex = index; currentIndex = index;
getPageWithOrOutPadding();
}); });
} }
Widget getPageWithOrOutPadding(){
if (pages[currentIndex] is TodayPage){
return Placeholder(
child: pages[currentIndex],
);
}else{
return Padding(
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 8),
child: pages[currentIndex],
);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Title'), title: const Text('Title'),
), ),
body: pages[currentIndex], body: getPageWithOrOutPadding(),
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: BottomNavigationBar(
currentIndex: currentIndex, currentIndex: currentIndex,
selectedItemColor: Colors.black54, selectedItemColor: Colors.black54,

View File

@ -1,5 +1,8 @@
import 'package:flutter/cupertino.dart'; import 'package:ernaehrung/components/diet_chart_component.dart';
import 'package:ernaehrung/components/statistics_circular_indicator_component.dart';
import 'package:ernaehrung/mockdata.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../components/card_component.dart';
class TodayPage extends StatefulWidget { class TodayPage extends StatefulWidget {
final String title; final String title;
@ -11,228 +14,39 @@ class TodayPage extends StatefulWidget {
} }
class _TodayPageState extends State<TodayPage> { class _TodayPageState extends State<TodayPage> {
String calories = "123 Cals"; List<CardComponent> getCardComponent() {
List<CardComponent> listOfCards = [];
cards.forEach((key, value) {
listOfCards.add(CardComponent(
key.keys.elementAt(0), key.values.elementAt(0), 300, value.toList()));
});
return listOfCards;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: SingleChildScrollView( body: SizedBox(
child: Column( width: double.infinity,
children: <Widget>[ height: double.infinity,
Card( child: Container(
shape: RoundedRectangleBorder( decoration: const BoxDecoration(
borderRadius: BorderRadius.circular(5), // if you need this gradient: LinearGradient(
side: BorderSide( colors: [Color(0xff000000), Color(0xff47a44b)],
color: Colors.grey.withOpacity(.2), stops: [0.1, 5],
width: 1, begin: Alignment.bottomCenter,
), end: Alignment.topCenter,
)
), ),
child: Column( child: Column(
children: [ children: [
Row( StatisticsPercentComponent(300, 100, 400),
mainAxisAlignment: MainAxisAlignment.spaceBetween, DietChatComponent(1500),
children: [Text('Frühstück'), Text('Cals 123')], SingleChildScrollView(child: Column(children: getCardComponent()))
),
SizedBox(
height: 200,
child: Stack(
children: <Widget>[
SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Padding(
padding: EdgeInsets.fromLTRB(8.0, 13.0, 8.0, 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: 50.0,
width: 60.0,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image.network(
'https://onlinejpgtools.com/images/examples-onlinejpgtools/coffee-resized.jpg',
fit: BoxFit.cover,
),
),
),
SizedBox(
width: 8,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Cafe Coffee Day',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
Text(
'Alpha 1, Greater Noida',
style: TextStyle(color: Colors.grey),
),
],
),
], ],
), ),
), ),
Divider( ));
color: Colors.black,
thickness: .2,
indent: 8,
endIndent: 8,
),
Padding(
padding: EdgeInsets.fromLTRB(8.0, 13.0, 8.0, 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: 50.0,
width: 60.0,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image.network(
'https://onlinejpgtools.com/images/examples-onlinejpgtools/coffee-resized.jpg',
fit: BoxFit.cover,
),
),
),
SizedBox(
width: 8,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Cafe Coffee Day',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
Text(
'Alpha 1, Greater Noida',
style: TextStyle(color: Colors.grey),
),
],
),
],
),
),
Divider(
color: Colors.black,
thickness: .2,
indent: 8,
endIndent: 8,
),
Padding(
padding: EdgeInsets.fromLTRB(8.0, 13.0, 8.0, 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: 50.0,
width: 60.0,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image.network(
'https://onlinejpgtools.com/images/examples-onlinejpgtools/coffee-resized.jpg',
fit: BoxFit.cover,
),
),
),
SizedBox(
width: 8,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Cafe Coffee Day',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
Text(
'Alpha 1, Greater Noida',
style: TextStyle(color: Colors.grey),
),
],
),
],
),
),
Divider(
color: Colors.black,
thickness: .2,
indent: 8,
endIndent: 8,
),
Padding(
padding: EdgeInsets.fromLTRB(8.0, 13.0, 8.0, 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: 50.0,
width: 60.0,
child: ClipRRect(
borderRadius: BorderRadius.circular(15.0),
child: Image.network(
'https://onlinejpgtools.com/images/examples-onlinejpgtools/coffee-resized.jpg',
fit: BoxFit.cover,
),
),
),
SizedBox(
width: 8,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Cafe Coffee Day',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
Text(
'Alpha 1, Greater Noida',
style: TextStyle(color: Colors.grey),
),
],
),
],
),
),
Divider(
color: Colors.black,
thickness: .2,
indent: 8,
endIndent: 8,
),
],
),
),
],
),
),
TextButton(onPressed: (){}, child: Text("Test"),
style: ButtonStyle(),)
]
),
),
],
)));
} }
} }

View File

View File

@ -1,5 +1,3 @@
import 'package:card_swiper/card_swiper.dart';
import 'package:ernaehrung/components/cardComponent.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class NavigationScreen extends StatefulWidget { class NavigationScreen extends StatefulWidget {
@ -33,7 +31,6 @@ class NavigationScreenState extends State<NavigationScreen> {
), ),
body: PageView( body: PageView(
controller: _pageController, controller: _pageController,
children: _widgetOptions,
onPageChanged: (int index) { onPageChanged: (int index) {
setState(() { setState(() {
_selectedPage = _pages[index]; _selectedPage = _pages[index];
@ -61,28 +58,4 @@ class NavigationScreenState extends State<NavigationScreen> {
), ),
); );
} }
static final List<Widget> _widgetOptions = <Widget>[
Swiper(
itemBuilder: (BuildContext context, int index) {
return const CardComponent();
},
itemCount: 1,
loop: false,
),
Swiper(
itemBuilder: (BuildContext context, int index) {
return const CardComponent();
},
itemCount: 1,
loop: false,
),
Swiper(
itemBuilder: (BuildContext context, int index) {
return const CardComponent();
},
itemCount: 1,
loop: false,
),
];
} }

View File

View File

@ -1,4 +1,4 @@
import 'package:ernaehrung/components/welcomePageChildrenTextField.dart'; import 'package:ernaehrung/components/welcome_text_field.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class WelcomeScreen extends StatelessWidget { class WelcomeScreen extends StatelessWidget {

View File

@ -1,6 +1,14 @@
# Generated by pub # Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
animate_gradient:
dependency: "direct main"
description:
name: animate_gradient
sha256: de5fa49579fed8184a9d9d30c3f46a74a3227ba148d283c20bc0e92ed9cc1545
url: "https://pub.dev"
source: hosted
version: "0.0.2"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -131,6 +139,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.2" version: "1.8.2"
percent_indicator:
dependency: "direct main"
description:
name: percent_indicator
sha256: c37099ad833a883c9d71782321cb65c3a848c21b6939b6185f0ff6640d05814c
url: "https://pub.dev"
source: hosted
version: "4.2.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -194,4 +210,4 @@ packages:
version: "2.1.4" version: "2.1.4"
sdks: sdks:
dart: ">=2.19.6 <3.0.0" dart: ">=2.19.6 <3.0.0"
flutter: ">=0.1.4" flutter: ">=2.12.0"

View File

@ -35,6 +35,8 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
animate_gradient: ^0.0.2
percent_indicator: ^4.0.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@ -57,7 +59,12 @@ flutter:
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in
# the material Icons class. # the material Icons class.
uses-material-design: true uses-material-design: true
assets:
- assets/json/csvjson_full.json
- assets/json/csvjson_minified.json
- assets/images/fries.png
- assets/images/ice.png
- assets/images/tea.png
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg