diff --git a/.github/ISSUE_TEMPLATE/1_bug.md b/.github/ISSUE_TEMPLATE/1_bug.md
new file mode 100644
index 000000000..e12f7506c
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/1_bug.md
@@ -0,0 +1,34 @@
+---
+name: I found a problem with wger
+about: While using wger the application crashes or throws an exception, a
+ widget is buggy, or something looks wrong.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+## Steps to Reproduce
+
+
+
+1. ...
+2. ...
+3. ...
+
+**Expected results:**
+
+**Actual results:**
+
+
+ Logs
+
+
+
+```
+```
+
+
+
diff --git a/.github/ISSUE_TEMPLATE/2_feature_request.md b/.github/ISSUE_TEMPLATE/2_feature_request.md
new file mode 100644
index 000000000..924b1e420
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/2_feature_request.md
@@ -0,0 +1,26 @@
+---
+name: Feature request
+about: Suggest a new idea for wger.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+## Use case
+
+
+
+## Proposal
+
+
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 000000000..6b0a08bd6
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,5 @@
+blank_issues_enabled: true
+contact_links:
+ - name: Get in touch with the community
+ url: https://discord.gg/rPWFv6W
+ about: Hop on the Discord server if you want to discuss new features or problem with us
diff --git a/Gemfile.lock b/Gemfile.lock
index a4c797786..0f31a7393 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -7,8 +7,8 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.1.1)
- aws-partitions (1.432.0)
- aws-sdk-core (3.113.0)
+ aws-partitions (1.443.0)
+ aws-sdk-core (3.113.1)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
@@ -16,7 +16,7 @@ GEM
aws-sdk-kms (1.43.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
- aws-sdk-s3 (1.91.0)
+ aws-sdk-s3 (1.93.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
@@ -48,7 +48,7 @@ GEM
faraday_middleware (1.0.0)
faraday (~> 1.0)
fastimage (2.2.3)
- fastlane (2.178.0)
+ fastlane (2.180.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
artifactory (~> 3.0)
@@ -105,7 +105,7 @@ GEM
rexml
signet (~> 0.14)
webrick
- google-apis-iamcredentials_v1 (0.2.0)
+ google-apis-iamcredentials_v1 (0.3.0)
google-apis-core (~> 0.1)
google-apis-storage_v1 (0.3.0)
google-apis-core (~> 0.1)
@@ -123,7 +123,7 @@ GEM
google-cloud-core (~> 1.2)
googleauth (~> 0.9)
mini_mime (~> 1.0)
- googleauth (0.16.0)
+ googleauth (0.16.1)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
@@ -139,7 +139,7 @@ GEM
jwt (2.2.2)
memoist (0.16.2)
mini_magick (4.11.0)
- mini_mime (1.0.2)
+ mini_mime (1.1.0)
multi_json (1.15.0)
multipart-post (2.0.0)
nanaimo (0.3.0)
@@ -153,7 +153,7 @@ GEM
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
- rexml (3.2.4)
+ rexml (3.2.5)
rouge (2.0.7)
ruby2_keywords (0.0.4)
rubyzip (2.3.0)
diff --git a/LICENSE b/LICENSE
index f288702d2..dba13ed2d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,23 +1,21 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
+our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
+software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
The precise terms and conditions for copying, distribution and
modification follow.
@@ -72,7 +60,7 @@ modification follow.
0. Definitions.
- "This License" refers to version 3 of the GNU General Public License.
+ "This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
- 13. Use with the GNU Affero General Public License.
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
+under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
+Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
+GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
+versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
+ 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 General Public License for more details.
+ GNU Affero General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
diff --git a/README.md b/README.md
index bca50522a..21fb1e20b 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,9 @@ IP address of the server)
You can run the tests with ``flutter test --no-sound-null-safety``
## Translation
-Translate the app to your language on [Hosted Weblate](https://hosted.weblate.org/engage/wger/).
+Translate the app to your language on [Weblate](https://hosted.weblate.org/engage/wger/).
+
+[](https://hosted.weblate.org/engage/wger/)
## Contact
@@ -57,7 +59,15 @@ If you're not sure if something is a bug or not, feel free to file a bug anyway.
## License
-The application is licensed under the GNU Affero General Public License 3 or later (AGPL 3+).
+The application is licensed under the GNU Affero General Public License 3 or later
+(AGPL 3+) with an app store exception.
+
+As an additional permission under section 7, you are allowed to distribute the
+software through an app store, even if that store has restrictive terms and
+conditions that are incompatible with the AGPL, provided that the source is also
+available under the AGPL with or without this permission through a channel without
+those restrictive terms and conditions.
+
The initial exercise and ingredient data is licensed additionally under one of
the Creative Commons licenses, see the individual exercises for more details.
diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile
index 9a7dd2212..2029ef8f4 100644
--- a/android/fastlane/Fastfile
+++ b/android/fastlane/Fastfile
@@ -25,8 +25,27 @@ end
platform :android do
-desc "Upload closed alpha app and update store entry"
- lane :updateclosed_alpha do
+ desc "Upload app to production"
+ lane :production do
+ begin
+ # gradle(
+ # task: 'assemble',
+ # build_type: 'Release'
+ #)
+ upload_to_play_store(
+ track: 'production',
+ aab: '../build/app/outputs/bundle/release/app-release.aab',
+ skip_upload_metadata: false,
+ skip_upload_images: false,
+ skip_upload_screenshots: true,
+ release_status: "completed", #"draft",
+ )
+ end
+ end
+
+
+ desc "Upload closed alpha app and update store entry"
+ lane :update_alpha do
begin
upload_to_play_store(
track: 'alpha',
@@ -39,21 +58,6 @@ desc "Upload closed alpha app and update store entry"
end
end
-
- desc "Runs all the tests"
- lane :test do
- gradle(task: "test")
- end
-
- desc "Submit a new Beta Build to Crashlytics Beta"
- lane :beta do
- gradle(task: "clean assembleRelease")
- crashlytics
-
- # sh "your_script.sh"
- # You can also use other beta testing services here
- end
-
desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(task: "clean assembleRelease")
diff --git a/android/fastlane/README.md b/android/fastlane/README.md
index 18f05e093..b925fd02d 100644
--- a/android/fastlane/README.md
+++ b/android/fastlane/README.md
@@ -24,21 +24,16 @@ fastlane playstore
----
## Android
-### android updateclosed_alpha
+### android production
```
-fastlane android updateclosed_alpha
+fastlane android production
+```
+Upload app to production
+### android update_alpha
+```
+fastlane android update_alpha
```
Upload closed alpha app and update store entry
-### android test
-```
-fastlane android test
-```
-Runs all the tests
-### android beta
-```
-fastlane android beta
-```
-Submit a new Beta Build to Crashlytics Beta
### android deploy
```
fastlane android deploy
diff --git a/android/fastlane/metadata/android/de-DE/full_description.txt b/android/fastlane/metadata/android/de-DE/full_description.txt
index 831d10d92..c198bbe82 100644
--- a/android/fastlane/metadata/android/de-DE/full_description.txt
+++ b/android/fastlane/metadata/android/de-DE/full_description.txt
@@ -1,3 +1,39 @@
-wger (ˈvɛɡɐ) Workout Manager ist eine kostenlose Open-Source-Anwendung, mit der Sie Ihre persönlichen Trainings-, Gewichts- und Diätpläne verwalten können
+Von Fitnessliebhabern für Fitnessliebhaber - organisiere deine Gesundheit mit WGER, deinem Workout Manager!
-TODO...
+Hast du schon deine #1 Fitness-App gefunden und liebst es, deine eigene Trainingspläne zu erstellen? Egal was für ein sportliches Biest du bist sind - wir haben alle etwas gemeinsam: wir lieben es, den Überblick über unsere Gesundheitsdaten zu behalten <3
+
+Wir verurteilen dich also nicht dafür, dass du deine Fitness-Reise immer noch mit deinem kleinen Logbuch verwaltest, aber willkommen im Jahr 2021!
+
+Wir haben eine 100% kostenlose digitale Gesundheits- und Fitnesstracker-App für dich entwickelt, die auf die wichtigsten Funktionen reduziert ist, um dein Leben einfacher zu machen. Lege jetzt lost, trainiere weiter und feiere deine Ihre Fortschritte!
+
+wger ist ein Open-Source-Projekt und dreht sich um:
+* Deinen Körper
+* Deine Workouts
+* Deine Fortschritte
+* Deine Daten
+
+Dein Körper:
+Du musst nicht mehr nach den Zutaten deiner Lieblingsspeise googeln - stelle deine täglichen Mahlzeiten aus mehr als 78000 Produkten und deren Nährwerte her. Füge Mahlzeiten zum Ernährungsplan hinzu und behalte den Überblick über deine Ernährung im Kalender.
+
+Deine Workouts:
+Du weißt, was das Beste für Ihren Körper ist. Erstelle deine eigenen Workouts aus einer wachsenden Vielfalt von 200 verschiedenen Übungen. Verwende dann den Gym-Modus, um dich durch das Training zu führen, während du deine Gewichte und Wiederholungen mit einem Tippen protokollieren kannst.
+
+Dein Fortschritt:
+Verlieren nie deine Ziele aus den Augen, tracke dein Gewicht und behalte deine Statistiken.
+
+Deine Daten:
+wger ist dein persönliches Fitness-Tagebuch - aber deine Daten gehören Dir. Nutze die REST-API, um darauf zuzugreifen und erstaunliche Dinge damit zu tun.
+
+Bitte beachte: Diese kostenlose App basiert nicht auf zusätzlichen Finanzierungen und wir bitten dich nicht um Geldspenden. Vielmehr handelt es sich um ein Community-Projekt, das ständig wächst. Sei also jederzeit auf neue Funktionen vorbereitet!
+
+#OpenSource - was bedeutet das?
+
+Open Source bedeutet, dass der gesamte Quellcode für diese App und den Server, mit dem sie spricht, frei und für jeden verfügbar ist:
+* Willst du wger auf deinem eigenen Server für dich oder dein lokales Fitnessstudio laufen lassen? Nur zu!
+* Vermisst du ein Feature und willst es implementieren? Fang jetzt an!
+* Willst du überprüfen, dass etwas an Dritte gesendet wird? Das kannst du!
+
+Trete unserer Community bei und werde ein Teil von Sportbegeisterten und IT-Freaks aus aller Welt. Wir arbeiten ständig daran, die App an unsere Bedürfnisse anzupassen und zu optimieren. Wir freuen uns über deinen Input, du kannst jederzeit einsteigen und deine Wünsche und Ideen einbringen!
+
+-> finde den Quellcode auf https://github.com/wger-project
+-> stelle deine Fragen oder sag einfach "Hallo" auf unserem Discord Server https://discord.gg/rPWFv6W
diff --git a/android/fastlane/metadata/android/en-US/full_description.txt b/android/fastlane/metadata/android/en-US/full_description.txt
index c092a1259..27025dcd3 100644
--- a/android/fastlane/metadata/android/en-US/full_description.txt
+++ b/android/fastlane/metadata/android/en-US/full_description.txt
@@ -1,6 +1,39 @@
-wger (ˈvɛɡɐ) is copylefted libre software helping your health.
+From fitness lovers to fitness lovers – get your health organized with WGER, your Workout Manager!
-- Plan workouts and nutrition
-- Save exercises and comment them
-- Gym mode
-- Diary and tracking of development
+Have you already found your #1 fitness app and do you love to create your own sports routines? No matter what type of sporty beast you are – we all have something in common: We love to keep track of our health data <3
+
+So we don’t judge you for still managing your fitness journey with your handy little workout log book but welcome to 2021!
+
+We have developed a 100% free digital health and fitness tracker app for you, sized down to the most relevant features to make your life easier. Get started, keep training and celebrate your progress!
+
+wger is an Open Source project and all about:
+* Your Body
+* Your Workouts
+* Your Progress
+* Your Data
+
+Your Body:
+No need to google for the ingredients of your favourite treats – choose your daily meals from more than 78000 products and see the nutritional values. Add meals to the nutritional plan and keep an overview of your diet in the calendar.
+
+Your Workouts:
+You know what is best for your body. Create your own workouts out of a growing variety from 200 different exercises. Then, use the Gym Mode to guide you through the training while you log your weights with one tap.
+
+Your Progress:
+Never lose sight of your goals. Track your weight and keep your statistics.
+
+Your Data:
+wger is your personalized fitness diary – but you own your data. Use the REST API to access and do amazing things with it.
+
+Please note: This free app is not based on additional fundings and we don’t ask you to donate money. More than that it is a community project which is growing constantly. So be prepared for new features anytime!
+
+#OpenSource – what does that mean?
+
+Open Source means that the whole source code for this app and the server it talks to is free and available to anybody:
+* Do you want to run wger on your own server for you or your local gym? Go ahead!
+* Do you miss a feature and want to implement it? Start now!
+* Do you want to check that nothing is being sent anywhere? You can!
+
+Join our community and become a part of sport enthusiasts and IT geeks from all over the world. We keep working on adjusting and optimizing the app customized to our needs. We love your input so feel free to jump in anytime and contribute your wishes and ideas!
+
+-> find the source code on https://github.com/wger-project
+-> ask your questions or just say hello on our discord Server https://discord.gg/rPWFv6W
\ No newline at end of file
diff --git a/android/fastlane/metadata/android/en-US/title.txt b/android/fastlane/metadata/android/en-US/title.txt
index d35e40870..ea0df9560 100644
--- a/android/fastlane/metadata/android/en-US/title.txt
+++ b/android/fastlane/metadata/android/en-US/title.txt
@@ -1 +1 @@
-wger Workout Manager
+wger Workout Manager
\ No newline at end of file
diff --git a/android/fastlane/metadata/android/fr/full_description.txt b/android/fastlane/metadata/android/fr-FR/full_description.txt
similarity index 100%
rename from android/fastlane/metadata/android/fr/full_description.txt
rename to android/fastlane/metadata/android/fr-FR/full_description.txt
diff --git a/android/fastlane/metadata/android/fr/short_description.txt b/android/fastlane/metadata/android/fr-FR/short_description.txt
similarity index 100%
rename from android/fastlane/metadata/android/fr/short_description.txt
rename to android/fastlane/metadata/android/fr-FR/short_description.txt
diff --git a/android/fastlane/metadata/android/fr-FR/title.txt b/android/fastlane/metadata/android/fr-FR/title.txt
new file mode 100644
index 000000000..ea0df9560
--- /dev/null
+++ b/android/fastlane/metadata/android/fr-FR/title.txt
@@ -0,0 +1 @@
+wger Workout Manager
\ No newline at end of file
diff --git a/android/fastlane/metadata/android/it-IT/full_description.txt b/android/fastlane/metadata/android/it-IT/full_description.txt
new file mode 100644
index 000000000..a0cf8a3b3
--- /dev/null
+++ b/android/fastlane/metadata/android/it-IT/full_description.txt
@@ -0,0 +1,39 @@
+Da amanti del fitness per amanti del fitness – Organizza la tua salute con wger il tuo gestore dell'allenamento!
+
+Hai già trovato la tua applicazione per il fitness #1 E ti piace creare le tue routines sportive? Non importa che tipo di sportivo sei – Abbiamo tutti qualcosa in comune: Amiamo tenere sotto controllo i dati sulla nostra salute <3
+
+Quindi non ti giudichiamo se stai ancora tenendo traccia dei tuoi allenamenti con un vecchio quaderno, ma ora ti diamo il benvenuto nel 2021!
+
+Abbiamo sviluppato una applicazione 100% gratuita, questa applicazione tiene traccia dei tuoi allenamenti per te alleggerita alle funzionalità più importanti per semplificarti la vita. Inizia, monitora, e celebra i tuoi progressi!
+
+wger è un progetto open source ed fatto per:
+* Il tuo corpo
+* Il tuo allenamento
+* I tuoi progressi
+* I tuoi dati
+
+Il tuo corpo:
+Nessuna necessità di chiedere a Google gli ingredienti dei tuoi pasti preferiti – Scegli i tuoi pasti quotidiani tra più di 78000 prodotti e verifica i valori nutrizionali. Aggiungi pasti al piano nutrizionale e ottieni una panoramica della tua dieta nel calendario.
+
+I tuoi allenamenti:
+Conosci cosa è meglio per il tuo corpo. Crea i tuoi allenamenti con un crescente numero di esercizi. Oltre 200. Poi, usa la modalità palestra per guidarti attraverso l'allenamento. Mentre registri i tuoi pesi con un tap.
+
+I tuoi progressi:
+Non perdere traccia dei tuoi progressi. Monitora il tuo peso e le tue statistiche.
+
+I tuoi dati:
+wger è un diario del fitness personalizzato – Dove possiedi i tuoi dati. Accedici con le API messe a disposizione.
+
+Per favore nota una cosa: Questa applicazione è gratuita e non è finanziata da terzi e non ti chiediamo di donare. Questo progetto è sviluppato dalla comunità in costante crescita. Quindi resta preparato a nuove funzionalità in ogni momento.
+
+#OpenSource – cosa vuole dire?
+
+Open Source significa che tutto il codice sorgente della applicazione, e del server alla quale comunica, è libero e disponibile a chiunque.
+* Vuoi installare il tuo server wger? Così da averlo nella tua palestra? Fai pure.
+* Ti mancano funzionalità e le vuoi implementare? Inizia ora.
+* Vuoi controllare che nessun dato è inviato a terzi? Puoi farlo!
+
+Entra a far parte della nostra community e diventa e unisciti agli entusiasti dello sport e nerd IT in tutto il mondo. Continuiamo a migliorare e ottimizzare la app personalizzata alle tue necessità. Amiamo ricevere consigli e idee quindi sentiti libero di unirti a noi in ogni momento e contribuire con i tuoi desideri e le tue idee!
+
+-> trovi il codice sorgente qui: https://github.com/wger-project
+-> fai le tue domante o semplicemente di ciao nel server Discord: https://discord.gg/rPWFv6W
diff --git a/android/fastlane/metadata/android/it/short_description.txt b/android/fastlane/metadata/android/it-IT/short_description.txt
similarity index 100%
rename from android/fastlane/metadata/android/it/short_description.txt
rename to android/fastlane/metadata/android/it-IT/short_description.txt
diff --git a/android/fastlane/metadata/android/it-IT/title.txt b/android/fastlane/metadata/android/it-IT/title.txt
new file mode 100644
index 000000000..d35e40870
--- /dev/null
+++ b/android/fastlane/metadata/android/it-IT/title.txt
@@ -0,0 +1 @@
+wger Workout Manager
diff --git a/android/fastlane/metadata/android/it/full_description.txt b/android/fastlane/metadata/android/it/full_description.txt
deleted file mode 100644
index 143039a3a..000000000
--- a/android/fastlane/metadata/android/it/full_description.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-wger (ˈvɛɡɐ) è un software libero che aiuta la tua saluta
-
-- Pianifica allenamento e dieta
-- Salva gli esercizi e aggiungi note
-- modalità allenamento
-- Diario e monitoraggio dello sviluppo
diff --git a/android/fastlane/report.xml b/android/fastlane/report.xml
index 36206176d..c165153e7 100644
--- a/android/fastlane/report.xml
+++ b/android/fastlane/report.xml
@@ -5,12 +5,12 @@
-
+
-
+
diff --git a/lib/helpers/consts.dart b/lib/helpers/consts.dart
index 2a77ddfc9..37f3318ac 100644
--- a/lib/helpers/consts.dart
+++ b/lib/helpers/consts.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
/// Size for the "smaller" icons, e.g. when they belong to less important items
@@ -22,7 +22,6 @@ const double ICON_SIZE_SMALL = 20;
/// Default wger server during login
const DEFAULT_SERVER = 'https://wger.rge.uber.space';
-//final DEFAULT_SERVER = 'http://localhost:8000';
/// Default weight unit is "kg"
const DEFAULT_WEIGHT_UNIT = 1;
diff --git a/lib/helpers/json.dart b/lib/helpers/json.dart
index c6d8e2053..e5f288f39 100644
--- a/lib/helpers/json.dart
+++ b/lib/helpers/json.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/lib/helpers/misc.dart b/lib/helpers/misc.dart
new file mode 100644
index 000000000..4e40b5521
--- /dev/null
+++ b/lib/helpers/misc.dart
@@ -0,0 +1,60 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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.
+ *
+ * wger Workout Manager 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 .
+ */
+
+import 'package:wger/helpers/consts.dart';
+import 'package:wger/models/workouts/repetition_unit.dart';
+import 'package:wger/models/workouts/weight_unit.dart';
+
+/// Returns the text representation for a single setting, used in the gym mode
+String repText(
+ int? reps,
+ RepetitionUnit repetitionUnitObj,
+ num? weight,
+ WeightUnit weightUnitObj,
+ String? rir,
+) {
+ // TODO: how to (easily?) translate strings like the units or 'RiR'?
+
+ List out = [];
+
+ if (reps != null) {
+ out.add(reps.toString());
+
+ // The default repetition unit is 'reps', which we don't show unless there
+ // is no weight defined so that we don't just output something like "8" but
+ // rather "8 repetitions". If there is weight we want to output "8 x 50kg",
+ // since the repetitions are implied. If other units are used, we always
+ // print them
+ if (repetitionUnitObj.id != DEFAULT_REPETITION_UNIT || weight == 0 || weight == null) {
+ out.add(repetitionUnitObj.name);
+ }
+ }
+
+ if (weight != null && weight != 0) {
+ out.add('×');
+ out.add(weight.toString());
+ out.add(weightUnitObj.name);
+ }
+
+ if (rir != null && rir != '') {
+ out.add('\n');
+ out.add('($rir RiR)');
+ }
+
+ return out.join(' ');
+}
diff --git a/lib/helpers/ui.dart b/lib/helpers/ui.dart
index c6ae1e976..fc16db870 100644
--- a/lib/helpers/ui.dart
+++ b/lib/helpers/ui.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:developer';
diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb
index 46773f9a4..9c3df9acd 100644
--- a/lib/l10n/app_de.arb
+++ b/lib/l10n/app_de.arb
@@ -254,7 +254,7 @@
"@login": {
"description": "Text for login button"
},
- "addExercise": "Diesem Tag eine Übung hinzufügen",
+ "addExercise": "Eine Übung hinzufügen",
"@addExercise": {},
"confirmDelete": "Sind Sie sicher, dass Sie \"{toDelete}\" löschen möchten?",
"@confirmDelete": {
@@ -273,5 +273,52 @@
"noWorkoutPlans": "Sie haben keine Trainingspläne",
"@noWorkoutPlans": {
"description": "Message shown when the user has no workout plans"
+ },
+ "nrOfSets": "Anzahl der Sätze: {nrOfSets}",
+ "@nrOfSets": {
+ "description": "Label shown on the slider where the user selects the nr of sets",
+ "type": "text",
+ "placeholders": {
+ "nrOfSets": {}
+ }
+ },
+ "enterCharacters": "Bitte gebe zwischen {min} und {max} Zeichen ein",
+ "@enterCharacters": {
+ "description": "Error message when the user hasn't entered the correct number of characters in a form",
+ "type": "text",
+ "placeholders": {
+ "min": {},
+ "max": {}
+ }
+ },
+ "selectExercise": "Bitte wähle eine Übung aus",
+ "@selectExercise": {
+ "description": "Error message when the user hasn't selected an exercise in the form"
+ },
+ "selectExercises": "Wenn du einen Supersatz machen willst, kannst du nach mehreren Übungen suchen, sie werden dann gruppiert",
+ "@selectExercises": {},
+ "sameRepetitions": "Wenn du für alle Sätze die gleichen Wiederholungen und das gleiche Gewicht verwendest, kannst du nur eine Zeile ausfüllen. Gebe z. B. für 4 Sätze einfach 10 für die Wiederholungen ein, daraus wird automatisch \"4 x 10\".",
+ "@sameRepetitions": {},
+ "setNr": "Satz {nr}",
+ "@setNr": {
+ "description": "Header in form indicating the number of the current set. Can also be translated as something like 'Set Nr. xy'.",
+ "type": "text",
+ "placeholders": {
+ "nr": {}
+ }
+ },
+ "dayDescriptionHelp": "Eine Beschreibung was an diesem Tag gemacht wird (z. B. \"Zugtag\") oder welche Körperteile trainiert werden (z. B. \"Brust und Schultern\")",
+ "@dayDescriptionHelp": {},
+ "set": "Satz",
+ "@set": {
+ "description": "A set in a workout plan"
+ },
+ "repetitionUnit": "Wiederholungseinheit",
+ "@repetitionUnit": {},
+ "weightUnit": "Gewichtseinheit",
+ "@weightUnit": {},
+ "reps": "Whd",
+ "@reps": {
+ "description": "Shorthand for repetitions, used when space constraints are tighter"
}
}
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index dbe05122a..44337b99b 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -4,6 +4,10 @@
"@login": {
"description": "Text for login button"
},
+ "logout": "Log out",
+ "@logout": {
+ "description": "Text for logout button"
+ },
"register": "Register",
"@register": {
"description": "Text for registration button"
@@ -64,6 +68,10 @@
"@labelWorkoutPlans": {
"description": "Title for screen workout plans"
},
+ "labelWorkoutLogs": "Training logs",
+ "@labelWorkoutLogs": {
+ "description": "(Workout) logs"
+ },
"labelWorkoutPlan": "Workout plan",
"@labelWorkoutPlan": {
"description": "Title for screen workout plan"
@@ -76,6 +84,10 @@
"@successfullyDeleted": {
"description": "Message when an item was successfully deleted"
},
+ "successfullySaved": "Saved successfully",
+ "@successfullySaved": {
+ "description": "Message when an item was successfully saved"
+ },
"exercise": "Exercise",
"@exercise": {
"description": "An exercise for a workout"
@@ -88,7 +100,7 @@
"@noWorkoutPlans": {
"description": "Message shown when the user has no workout plans"
},
- "addExercise": "Add exercise to this day",
+ "addExercise": "Add exercise",
"repetitions": "Repetitions",
"@repetitions": {
"description": "Repetitions for an exercise set"
@@ -107,6 +119,7 @@
"@set": {
"description": "A set in a workout plan"
},
+ "dayDescriptionHelp": "A description of what is done on this day (e.g. 'pull day') or what body parts are trained (e.g. 'chest and shoulders')",
"setNr": "Set {nr}",
"@setNr": {
"description": "Header in form indicating the number of the current set. Can also be translated as something like 'Set Nr. xy'.",
@@ -115,7 +128,7 @@
"nr": {}
}
},
- "sameRepetitions": "If you do the same repetitions and weight for all sets you can just fill in one row. For example for 4 sets just enter one \"10\" for the repetitions, this automatically becomes \"4 x 10\".",
+ "sameRepetitions": "If you do the same repetitions and weight for all sets you can just fill in one row. For example for 4 sets just enter 10 for the repetitions, this automatically becomes \"4 x 10\".",
"comment": "Comment",
"@comment": {
"description": "Comment, additional information"
@@ -154,8 +167,10 @@
"@save": {},
"cancel": "Cancel",
"@cancel": {},
- "add": "Add",
- "@add": {},
+ "addSet": "Add set",
+ "@addSet": {
+ "description": "Label for the button that adds a set (to a workout day)"
+ },
"addMeal": "Add meal",
"@addMeal": {},
"mealLogged": "Meal logged to diary",
@@ -184,6 +199,10 @@
"@date": {
"description": "The date of a workout log or body weight entry"
},
+ "start": "Start",
+ "@start": {
+ "description": "Label on button to start the gym mode (i.e., an imperative)"
+ },
"time": "Time",
"@time": {
"description": "The time of a meal or workout"
@@ -276,6 +295,10 @@
"@goToToday": {
"description": "Label on button to jump back to 'today' in the calendar widget"
},
+ "enterRepetitionsOrWeight": "Please fill in either the repetitions or the weight for at least one of the sets",
+ "@enterRepetitionsOrWeight": {
+ "description": "Error message when the user hasn't filled in the forms for exercise sets"
+ },
"enterValue": "Please enter a value",
"@enterValue": {
"description": "Error message when the user hasn't entered a value on a required field"
diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb
index 971ec5677..03c1abef6 100644
--- a/lib/l10n/app_fr.arb
+++ b/lib/l10n/app_fr.arb
@@ -177,7 +177,7 @@
"@repetitions": {
"description": "Repetitions for an exercise set"
},
- "addExercise": "Ajoute un exercice à cet journée",
+ "addExercise": "Ajoute un exercice",
"@addExercise": {},
"noWorkoutPlans": "Aucune plan d'entraînement",
"@noWorkoutPlans": {
@@ -266,5 +266,17 @@
"login": "Se connecter",
"@login": {
"description": "Text for login button"
+ },
+ "set": "Série",
+ "@set": {
+ "description": "A set in a workout plan"
+ },
+ "repetitionUnit": "Unité des répétitions",
+ "@repetitionUnit": {},
+ "weightUnit": "Unité de poids",
+ "@weightUnit": {},
+ "reps": "Répétitions",
+ "@reps": {
+ "description": "Shorthand for repetitions, used when space constraints are tighter"
}
}
diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb
index 681d38b28..8795e8fdb 100644
--- a/lib/l10n/app_it.arb
+++ b/lib/l10n/app_it.arb
@@ -177,7 +177,7 @@
"@repetitions": {
"description": "Repetitions for an exercise set"
},
- "addExercise": "Aggiungi esercizi per questo giorno",
+ "addExercise": "Aggiungi esercizi",
"@addExercise": {},
"noWorkoutPlans": "Non hai nessun piano di allenamento",
"@noWorkoutPlans": {
@@ -266,5 +266,74 @@
"login": "Entra",
"@login": {
"description": "Text for login button"
+ },
+ "nrOfSets": "Numero di set: {nrOfSets}",
+ "@nrOfSets": {
+ "description": "Label shown on the slider where the user selects the nr of sets",
+ "type": "text",
+ "placeholders": {
+ "nrOfSets": {}
+ }
+ },
+ "enterCharacters": "Inserisci una stringa tra {min} e {max} caratteri",
+ "@enterCharacters": {
+ "description": "Error message when the user hasn't entered the correct number of characters in a form",
+ "type": "text",
+ "placeholders": {
+ "min": {},
+ "max": {}
+ }
+ },
+ "selectExercise": "Prego, seleziona un esercizio",
+ "@selectExercise": {
+ "description": "Error message when the user hasn't selected an exercise in the form"
+ },
+ "todaysWorkout": "Allenamento di oggi",
+ "@todaysWorkout": {},
+ "selectExercises": "Se vuoi fare un circuito (super set), puoi cercare e aggiungere diversi esercizi. Questi verranno collegati come circuito.",
+ "@selectExercises": {},
+ "sameRepetitions": "Se fai le stesse ripetizioni e peso per tutte le serie puoi compilare una sola riga. Per esempio per 4 serie inserisci semplicemente 10 per le ripetizioni, automaticamente diventerà una 4x10.",
+ "@sameRepetitions": {},
+ "setNr": "Serie {nr}",
+ "@setNr": {
+ "description": "Header in form indicating the number of the current set. Can also be translated as something like 'Set Nr. xy'.",
+ "type": "text",
+ "placeholders": {
+ "nr": {}
+ }
+ },
+ "dayDescriptionHelp": "Una descrizione di ciò che è stato fatto. (p.e. 'allenamento gambe') o quale parte del corpo sono state allenate (p.e. 'petto e spalle')",
+ "@dayDescriptionHelp": {},
+ "set": "Serie",
+ "@set": {
+ "description": "A set in a workout plan"
+ },
+ "repetitionUnit": "Unità ripetizioni",
+ "@repetitionUnit": {},
+ "weightUnit": "Unità peso",
+ "@weightUnit": {},
+ "reps": "Ripetizioni",
+ "@reps": {
+ "description": "Shorthand for repetitions, used when space constraints are tighter"
+ },
+ "addSet": "Aggiungi serie",
+ "@addSet": {
+ "description": "Label for the button that adds a set (to a workout day)"
+ },
+ "start": "Inizia",
+ "@start": {
+ "description": "Label on button to start the gym mode (i.e., an imperative)"
+ },
+ "successfullySaved": "Salvato con successo",
+ "@successfullySaved": {
+ "description": "Message when an item was successfully saved"
+ },
+ "labelWorkoutLogs": "Registri allenamenti",
+ "@labelWorkoutLogs": {
+ "description": "(Workout) logs"
+ },
+ "logout": "Disconnetti",
+ "@logout": {
+ "description": "Text for logout button"
}
}
diff --git a/lib/main.dart b/lib/main.dart
index a0a2a4586..8092024fd 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/lib/models/body_weight/weight_entry.dart b/lib/models/body_weight/weight_entry.dart
index bcc2a6900..ed8761bdf 100644
--- a/lib/models/body_weight/weight_entry.dart
+++ b/lib/models/body_weight/weight_entry.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
diff --git a/lib/models/exercises/category.dart b/lib/models/exercises/category.dart
index 6f93e46e3..9b15dc1b2 100644
--- a/lib/models/exercises/category.dart
+++ b/lib/models/exercises/category.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
@@ -28,7 +28,7 @@ class ExerciseCategory {
@JsonKey(required: true)
final String name;
- ExerciseCategory({
+ const ExerciseCategory({
required this.id,
required this.name,
});
diff --git a/lib/models/exercises/comment.dart b/lib/models/exercises/comment.dart
index 8c242300f..e9461502b 100644
--- a/lib/models/exercises/comment.dart
+++ b/lib/models/exercises/comment.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
diff --git a/lib/models/exercises/equipment.dart b/lib/models/exercises/equipment.dart
index f56bbf56c..ea7713b85 100644
--- a/lib/models/exercises/equipment.dart
+++ b/lib/models/exercises/equipment.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
@@ -28,7 +28,7 @@ class Equipment {
@JsonKey(required: true)
final String name;
- Equipment({
+ const Equipment({
required this.id,
required this.name,
});
diff --git a/lib/models/exercises/exercise.dart b/lib/models/exercises/exercise.dart
index e47686e19..2ee6f398a 100644
--- a/lib/models/exercises/exercise.dart
+++ b/lib/models/exercises/exercise.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
@@ -43,7 +43,7 @@ class Exercise {
final String description;
@JsonKey(required: false)
- final int categoryId;
+ late int categoryId;
@JsonKey(required: true, name: 'category')
late final ExerciseCategory categoryObj;
@@ -63,24 +63,27 @@ class Exercise {
@JsonKey(required: true, name: 'comments')
List tips = [];
- Exercise({
- required this.id,
- required this.uuid,
- required this.creationDate,
- required this.name,
- required this.description,
- required this.categoryId,
- List? muscles,
- List? musclesSecondary,
- List? equipment,
- List? images,
- List? tips,
- }) {
+ Exercise(
+ {required this.id,
+ required this.uuid,
+ required this.creationDate,
+ required this.name,
+ required this.description,
+ required this.categoryId,
+ List? muscles,
+ List? musclesSecondary,
+ List? equipment,
+ List? images,
+ List? tips,
+ ExerciseCategory? category}) {
this.tips = tips ?? [];
this.images = images ?? [];
this.equipment = equipment ?? [];
this.musclesSecondary = musclesSecondary ?? [];
this.muscles = muscles ?? [];
+ if (category != null) {
+ this.categoryObj = category;
+ }
}
ExerciseImage? get getMainImage {
@@ -91,6 +94,11 @@ class Exercise {
}
}
+ set category(ExerciseCategory category) {
+ this.categoryId = category.id;
+ this.categoryObj = category;
+ }
+
// Boilerplate
factory Exercise.fromJson(Map json) => _$ExerciseFromJson(json);
Map toJson() => _$ExerciseToJson(this);
diff --git a/lib/models/exercises/image.dart b/lib/models/exercises/image.dart
index c57b4a26e..38f9df738 100644
--- a/lib/models/exercises/image.dart
+++ b/lib/models/exercises/image.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
diff --git a/lib/models/exercises/muscle.dart b/lib/models/exercises/muscle.dart
index f4ddb82f5..19dac14f9 100644
--- a/lib/models/exercises/muscle.dart
+++ b/lib/models/exercises/muscle.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
@@ -31,7 +31,7 @@ class Muscle {
@JsonKey(name: 'is_front', required: true)
final bool isFront;
- Muscle({
+ const Muscle({
required this.id,
required this.name,
required this.isFront,
diff --git a/lib/models/http_exception.dart b/lib/models/http_exception.dart
index e6a018b11..d2d48ddc6 100644
--- a/lib/models/http_exception.dart
+++ b/lib/models/http_exception.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:convert';
diff --git a/lib/models/nutrition/ingredient.dart b/lib/models/nutrition/ingredient.dart
index 54d723866..f58ffcf4f 100644
--- a/lib/models/nutrition/ingredient.dart
+++ b/lib/models/nutrition/ingredient.dart
@@ -1,21 +1,20 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
-
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/helpers/json.dart';
diff --git a/lib/models/nutrition/ingredient_weight_unit.dart b/lib/models/nutrition/ingredient_weight_unit.dart
index 951608273..da71c9c10 100644
--- a/lib/models/nutrition/ingredient_weight_unit.dart
+++ b/lib/models/nutrition/ingredient_weight_unit.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
diff --git a/lib/models/nutrition/log.dart b/lib/models/nutrition/log.dart
index 2cf827281..cdb0155c3 100644
--- a/lib/models/nutrition/log.dart
+++ b/lib/models/nutrition/log.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
@@ -46,7 +46,7 @@ class Log {
late Ingredient ingredientObj;
@JsonKey(required: true, name: 'weight_unit')
- late int weightUnitId;
+ int? weightUnitId;
@JsonKey(ignore: true)
IngredientWeightUnit? weightUnitObj;
@@ -81,9 +81,9 @@ class Log {
// This is already done on the server. It might be better to read it from there.
var out = NutritionalValues();
- final weight = amount;
- // final weight =
- // this.weightUnitObj == null ? amount : amount * weightUnitObj.amount * weightUnitObj.grams;
+ //final weight = amount;
+ final weight =
+ this.weightUnitObj == null ? amount : amount * weightUnitObj!.amount * weightUnitObj!.grams;
out.energy = ingredientObj.energy * weight / 100;
out.protein = ingredientObj.protein * weight / 100;
diff --git a/lib/models/nutrition/log.g.dart b/lib/models/nutrition/log.g.dart
index 27cf722b8..0aedd882e 100644
--- a/lib/models/nutrition/log.g.dart
+++ b/lib/models/nutrition/log.g.dart
@@ -18,7 +18,7 @@ Log _$LogFromJson(Map json) {
return Log(
id: json['id'] as int?,
ingredientId: json['ingredient'] as int,
- weightUnitId: json['weight_unit'] as int,
+ weightUnitId: json['weight_unit'] as int?,
amount: toNum(json['amount'] as String?),
planId: json['plan'] as int,
datetime: DateTime.parse(json['datetime'] as String),
diff --git a/lib/models/nutrition/meal.dart b/lib/models/nutrition/meal.dart
index ae57244d9..b165e6e84 100644
--- a/lib/models/nutrition/meal.dart
+++ b/lib/models/nutrition/meal.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/lib/models/nutrition/meal_item.dart b/lib/models/nutrition/meal_item.dart
index 1dd7d107b..578da11c9 100644
--- a/lib/models/nutrition/meal_item.dart
+++ b/lib/models/nutrition/meal_item.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
@@ -30,29 +30,29 @@ class MealItem {
@JsonKey(required: true)
int? id;
- @JsonKey(required: false)
+ @JsonKey(required: false, name: 'meal')
late int mealId;
@JsonKey(required: false, name: 'ingredient')
- int ingredientId;
+ late int ingredientId;
@JsonKey(ignore: true)
late Ingredient ingredientObj;
@JsonKey(required: false, name: 'weight_unit')
- int weightUnitId;
+ int? weightUnitId;
@JsonKey(ignore: true)
- late IngredientWeightUnit weightUnitObj;
+ IngredientWeightUnit? weightUnitObj;
@JsonKey(required: true, fromJson: toNum, toJson: toString)
- num amount;
+ late num amount;
MealItem({
this.id,
int? mealId,
required this.ingredientId,
- required this.weightUnitId,
+ this.weightUnitId,
required this.amount,
}) {
if (mealId != null) {
@@ -60,6 +60,8 @@ class MealItem {
}
}
+ MealItem.empty();
+
// Boilerplate
factory MealItem.fromJson(Map json) => _$MealItemFromJson(json);
diff --git a/lib/models/nutrition/meal_item.g.dart b/lib/models/nutrition/meal_item.g.dart
index 1e4517ab0..4611e7bce 100644
--- a/lib/models/nutrition/meal_item.g.dart
+++ b/lib/models/nutrition/meal_item.g.dart
@@ -10,16 +10,16 @@ MealItem _$MealItemFromJson(Map json) {
$checkKeys(json, requiredKeys: const ['id', 'amount']);
return MealItem(
id: json['id'] as int?,
- mealId: json['mealId'] as int?,
+ mealId: json['meal'] as int?,
ingredientId: json['ingredient'] as int,
- weightUnitId: json['weight_unit'] as int,
+ weightUnitId: json['weight_unit'] as int?,
amount: toNum(json['amount'] as String?),
);
}
Map _$MealItemToJson(MealItem instance) => {
'id': instance.id,
- 'mealId': instance.mealId,
+ 'meal': instance.mealId,
'ingredient': instance.ingredientId,
'weight_unit': instance.weightUnitId,
'amount': toString(instance.amount),
diff --git a/lib/models/nutrition/nutritional_plan.dart b/lib/models/nutrition/nutritional_plan.dart
index 53f899983..292dd938b 100644
--- a/lib/models/nutrition/nutritional_plan.dart
+++ b/lib/models/nutrition/nutritional_plan.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
@@ -31,10 +31,10 @@ class NutritionalPlan {
int? id;
@JsonKey(required: true)
- String description;
+ late String description;
@JsonKey(required: true, name: 'creation_date', toJson: toDate)
- DateTime creationDate;
+ late DateTime creationDate;
@JsonKey(ignore: true, defaultValue: [])
List meals = [];
@@ -53,6 +53,11 @@ class NutritionalPlan {
this.logs = logs ?? [];
}
+ NutritionalPlan.empty() {
+ creationDate = DateTime.now();
+ description = '';
+ }
+
// Boilerplate
factory NutritionalPlan.fromJson(Map json) => _$NutritionalPlanFromJson(json);
Map toJson() => _$NutritionalPlanToJson(this);
diff --git a/lib/models/nutrition/nutritrional_values.dart b/lib/models/nutrition/nutritrional_values.dart
index bb1c86cef..4fd856f53 100644
--- a/lib/models/nutrition/nutritrional_values.dart
+++ b/lib/models/nutrition/nutritrional_values.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
diff --git a/lib/models/nutrition/weight_unit.dart b/lib/models/nutrition/weight_unit.dart
index df4bbf0cc..3bcab86ec 100644
--- a/lib/models/nutrition/weight_unit.dart
+++ b/lib/models/nutrition/weight_unit.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:json_annotation/json_annotation.dart';
diff --git a/lib/models/workouts/day.dart b/lib/models/workouts/day.dart
index fcb2243de..1a61b6e8e 100644
--- a/lib/models/workouts/day.dart
+++ b/lib/models/workouts/day.dart
@@ -1,3 +1,21 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/models/workouts/set.dart';
@@ -5,6 +23,16 @@ part 'day.g.dart';
@JsonSerializable()
class Day {
+ static const Map weekdays = {
+ 1: 'Monday',
+ 2: 'Tuesday',
+ 3: 'Wednesday',
+ 4: 'Thursday',
+ 5: 'Friday',
+ 6: 'Saturday',
+ 7: 'Sunday',
+ };
+
@JsonKey(required: true)
int? id;
@@ -28,27 +56,6 @@ class Day {
this.sets = [];
}
- Day.withData({
- required this.id,
- required this.workoutId,
- required this.description,
- List? daysOfWeek,
- List? sets,
- }) {
- this.daysOfWeek = daysOfWeek ?? [];
- this.sets = sets ?? [];
- }
-
- static const Map weekdays = {
- 1: 'Monday',
- 2: 'Tuesday',
- 3: 'Wednesday',
- 4: 'Thursday',
- 5: 'Friday',
- 6: 'Saturday',
- 7: 'Sunday',
- };
-
String getDayName(int weekDay) {
return weekdays[weekDay]!;
}
diff --git a/lib/models/workouts/log.dart b/lib/models/workouts/log.dart
index cff68aff3..94cd85682 100644
--- a/lib/models/workouts/log.dart
+++ b/lib/models/workouts/log.dart
@@ -1,5 +1,27 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/helpers/json.dart';
+import 'package:wger/helpers/misc.dart';
+import 'package:wger/models/exercises/exercise.dart';
+import 'package:wger/models/workouts/repetition_unit.dart';
+import 'package:wger/models/workouts/weight_unit.dart';
part 'log.g.dart';
@@ -8,8 +30,11 @@ class Log {
@JsonKey(required: true)
int? id;
- @JsonKey(required: true)
- late int exercise;
+ @JsonKey(required: true, name: 'exercise')
+ late int exerciseId;
+
+ @JsonKey(ignore: true)
+ late Exercise exerciseObj;
@JsonKey(required: true, name: 'workout')
late int workoutPlan;
@@ -18,16 +43,22 @@ class Log {
late int reps;
@JsonKey(required: false)
- late String rir;
+ String? rir;
@JsonKey(required: true, name: 'repetition_unit')
- late int repetitionUnit;
+ late int repetitionUnitId;
+
+ @JsonKey(ignore: true)
+ late RepetitionUnit repetitionUnitObj;
@JsonKey(required: true, fromJson: toNum, toJson: toString)
late num weight;
@JsonKey(required: true, name: 'weight_unit')
- late int weightUnit;
+ late int weightUnitId;
+
+ @JsonKey(ignore: true)
+ late WeightUnit weightUnitObj;
@JsonKey(required: true, toJson: toDate)
late DateTime date;
@@ -35,21 +66,44 @@ class Log {
//@JsonKey(required: true)
//String comment;
- Log();
+ Log(
+ {this.id,
+ required this.exerciseId,
+ required this.workoutPlan,
+ required this.reps,
+ required this.rir,
+ required this.repetitionUnitId,
+ required this.weight,
+ required this.weightUnitId,
+ required this.date});
- Log.withData({
- this.id,
- required this.exercise,
- required this.workoutPlan,
- required this.repetitionUnit,
- required this.reps,
- required this.rir,
- required this.weight,
- required this.weightUnit,
- required this.date,
- });
+ Log.empty();
// Boilerplate
factory Log.fromJson(Map json) => _$LogFromJson(json);
Map toJson() => _$LogToJson(this);
+
+ set exercise(Exercise exercise) {
+ this.exerciseObj = exercise;
+ this.exerciseId = exercise.id;
+ }
+
+ set weightUnit(WeightUnit weightUnit) {
+ this.weightUnitObj = weightUnit;
+ this.weightUnitId = weightUnit.id;
+ }
+
+ set repetitionUnit(RepetitionUnit repetitionUnit) {
+ this.repetitionUnitObj = repetitionUnit;
+ this.repetitionUnitId = repetitionUnit.id;
+ }
+
+ void setRir(String rir) {
+ this.rir = rir;
+ }
+
+ /// Returns the text representation for a single setting, used in the gym mode
+ String get singleLogRepText {
+ return repText(reps, repetitionUnitObj, weight, weightUnitObj, rir);
+ }
}
diff --git a/lib/models/workouts/log.g.dart b/lib/models/workouts/log.g.dart
index be478d010..309464a43 100644
--- a/lib/models/workouts/log.g.dart
+++ b/lib/models/workouts/log.g.dart
@@ -17,26 +17,27 @@ Log _$LogFromJson(Map json) {
'weight_unit',
'date'
]);
- return Log()
- ..id = json['id'] as int?
- ..exercise = json['exercise'] as int
- ..workoutPlan = json['workout'] as int
- ..reps = json['reps'] as int
- ..rir = json['rir'] as String
- ..repetitionUnit = json['repetition_unit'] as int
- ..weight = toNum(json['weight'] as String?)
- ..weightUnit = json['weight_unit'] as int
- ..date = DateTime.parse(json['date'] as String);
+ return Log(
+ id: json['id'] as int?,
+ exerciseId: json['exercise'] as int,
+ workoutPlan: json['workout'] as int,
+ reps: json['reps'] as int,
+ rir: json['rir'] as String?,
+ repetitionUnitId: json['repetition_unit'] as int,
+ weight: toNum(json['weight'] as String?),
+ weightUnitId: json['weight_unit'] as int,
+ date: DateTime.parse(json['date'] as String),
+ );
}
Map _$LogToJson(Log instance) => {
'id': instance.id,
- 'exercise': instance.exercise,
+ 'exercise': instance.exerciseId,
'workout': instance.workoutPlan,
'reps': instance.reps,
'rir': instance.rir,
- 'repetition_unit': instance.repetitionUnit,
+ 'repetition_unit': instance.repetitionUnitId,
'weight': toString(instance.weight),
- 'weight_unit': instance.weightUnit,
+ 'weight_unit': instance.weightUnitId,
'date': toDate(instance.date),
};
diff --git a/lib/models/workouts/repetition_unit.dart b/lib/models/workouts/repetition_unit.dart
index a43bf7d43..a732c9a12 100644
--- a/lib/models/workouts/repetition_unit.dart
+++ b/lib/models/workouts/repetition_unit.dart
@@ -1,3 +1,21 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:json_annotation/json_annotation.dart';
part 'repetition_unit.g.dart';
@@ -10,7 +28,7 @@ class RepetitionUnit {
@JsonKey(required: true)
final String name;
- RepetitionUnit({
+ const RepetitionUnit({
required this.id,
required this.name,
});
diff --git a/lib/models/workouts/session.dart b/lib/models/workouts/session.dart
index 65b9108af..46a1a9105 100644
--- a/lib/models/workouts/session.dart
+++ b/lib/models/workouts/session.dart
@@ -1,3 +1,21 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/helpers/json.dart';
diff --git a/lib/models/workouts/set.dart b/lib/models/workouts/set.dart
index eda7ea40c..8753a094f 100644
--- a/lib/models/workouts/set.dart
+++ b/lib/models/workouts/set.dart
@@ -1,3 +1,21 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/models/exercises/exercise.dart';
import 'package:wger/models/workouts/setting.dart';
@@ -60,6 +78,23 @@ class Set {
}
}
+ /// Return only one setting object per exercise, this makes rendering workout
+ /// plans easier and the gym mode uses the synthetic settings anyway.
+ List get settingsFiltered {
+ List out = [];
+
+ settings.forEach((setting) {
+ final foundSettings = out.where(
+ (element) => element.exerciseId == setting.exerciseId,
+ );
+
+ if (foundSettings.length == 0) {
+ out.add(setting);
+ }
+ });
+ return out;
+ }
+
void addExercise(Exercise exercise) {
exercisesObj.add(exercise);
exercisesIds.add(exercise.id);
diff --git a/lib/models/workouts/setting.dart b/lib/models/workouts/setting.dart
index 63d37ee72..d02ba5ebc 100644
--- a/lib/models/workouts/setting.dart
+++ b/lib/models/workouts/setting.dart
@@ -1,5 +1,24 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:json_annotation/json_annotation.dart';
import 'package:wger/helpers/json.dart';
+import 'package:wger/helpers/misc.dart';
import 'package:wger/models/exercises/exercise.dart';
import 'package:wger/models/workouts/repetition_unit.dart';
import 'package:wger/models/workouts/weight_unit.dart';
@@ -8,7 +27,8 @@ part 'setting.g.dart';
@JsonSerializable()
class Setting {
- static final possibleValues = ['1', '1.5', '2', '2.5', '3', '3.5'];
+ static const POSSIBLE_RIR_VALUES = ['', '1', '1.5', '2', '2.5', '3', '3.5'];
+ static const DEFAULT_RIR = '';
@JsonKey(required: true)
int? id;
@@ -49,7 +69,7 @@ class Setting {
@JsonKey(required: true)
String? rir = '';
- // Generated by Server
+ // Generated by the server
@JsonKey(ignore: true)
late String repsText = '';
@@ -71,26 +91,31 @@ class Setting {
factory Setting.fromJson(Map json) => _$SettingFromJson(json);
Map toJson() => _$SettingToJson(this);
- void setExercise(Exercise exercise) {
+ set exercise(Exercise exercise) {
exerciseObj = exercise;
exerciseId = exercise.id;
}
- void setWeightUnit(WeightUnit weightUnit) {
+ set weightUnit(WeightUnit weightUnit) {
weightUnitObj = weightUnit;
weightUnitId = weightUnit.id;
}
- void setRepetitionUnit(RepetitionUnit repetitionUnit) {
+ set repetitionUnit(RepetitionUnit repetitionUnit) {
repetitionUnitObj = repetitionUnit;
repetitionUnitId = repetitionUnit.id;
}
void setRir(String rir) {
- if (possibleValues.contains(rir)) {
+ if (POSSIBLE_RIR_VALUES.contains(rir)) {
this.rir = rir;
} else {
throw Exception('RiR value not allowed');
}
}
+
+ /// Returns the text representation for a single setting, used in the gym mode
+ String get singleSettingRepText {
+ return repText(reps, repetitionUnitObj, weight, weightUnitObj, rir);
+ }
}
diff --git a/lib/models/workouts/weight_unit.dart b/lib/models/workouts/weight_unit.dart
index 88aa74fbd..82463c758 100644
--- a/lib/models/workouts/weight_unit.dart
+++ b/lib/models/workouts/weight_unit.dart
@@ -1,3 +1,21 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:json_annotation/json_annotation.dart';
part 'weight_unit.g.dart';
@@ -10,7 +28,7 @@ class WeightUnit {
@JsonKey(required: true)
final String name;
- WeightUnit({
+ const WeightUnit({
required this.id,
required this.name,
});
diff --git a/lib/models/workouts/workout_plan.dart b/lib/models/workouts/workout_plan.dart
index 9d769ed7f..2e63967fb 100644
--- a/lib/models/workouts/workout_plan.dart
+++ b/lib/models/workouts/workout_plan.dart
@@ -57,7 +57,7 @@ class WorkoutPlan {
/// Filters the workout logs by exercise and sorts them by date
List filterLogsByExercise(Exercise exercise) {
- var out = logs.where((element) => element.exercise == exercise.id).toList();
+ var out = logs.where((element) => element.exerciseId == exercise.id).toList();
out.sort((a, b) => a.date.compareTo(b.date));
return out;
}
diff --git a/lib/providers/auth.dart b/lib/providers/auth.dart
index 4891742f6..089b2cd52 100644
--- a/lib/providers/auth.dart
+++ b/lib/providers/auth.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:async';
diff --git a/lib/providers/base_provider.dart b/lib/providers/base_provider.dart
index 8a9e206d5..4814f5365 100644
--- a/lib/providers/base_provider.dart
+++ b/lib/providers/base_provider.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:convert';
diff --git a/lib/providers/body_weight.dart b/lib/providers/body_weight.dart
index 285a6b624..fa92ade08 100644
--- a/lib/providers/body_weight.dart
+++ b/lib/providers/body_weight.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -39,6 +39,14 @@ class BodyWeight extends WgerBaseProvider with ChangeNotifier {
return _entries.firstWhere((plan) => plan.id == id);
}
+ WeightEntry? findByDate(DateTime date) {
+ try {
+ return _entries.firstWhere((plan) => plan.date == date);
+ } on StateError catch (e) {
+ return null;
+ }
+ }
+
Future> fetchAndSetEntries() async {
// Process the response
final data = await fetch(makeUrl(bodyWeightUrl, query: {'ordering': '-date'}));
diff --git a/lib/providers/exercises.dart b/lib/providers/exercises.dart
index e042f10e9..3844e6b11 100644
--- a/lib/providers/exercises.dart
+++ b/lib/providers/exercises.dart
@@ -1,24 +1,25 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
+import 'dart:io';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
@@ -117,11 +118,15 @@ class Exercises extends WgerBaseProvider with ChangeNotifier {
await fetchAndSetMuscles();
await fetchAndSetEquipment();
- final response = await client.get(makeUrl(
- _exercisesUrlPath,
- query: {'limit': '1000'},
- ));
- final exercisesData = json.decode(response.body) as Map;
+ final response = await client.get(
+ makeUrl(
+ _exercisesUrlPath,
+ query: {'limit': '1000'},
+ ),
+ headers: {
+ HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8',
+ });
+ final exercisesData = json.decode(utf8.decode(response.bodyBytes)) as Map;
try {
// Load exercises
@@ -149,14 +154,17 @@ class Exercises extends WgerBaseProvider with ChangeNotifier {
///
/// We could do this locally, but the server has better text searching capabilities
/// with postgresql.
- Future searchExercise(String name) async {
+ Future searchExercise(String name, [String languageCode = 'en']) async {
if (name.length <= 1) {
return [];
}
// Send the request
final response = await client.get(
- makeUrl(_exerciseSearchPath, query: {'term': name}),
+ makeUrl(
+ _exerciseSearchPath,
+ query: {'term': name, 'language': languageCode},
+ ),
headers: {
'Authorization': 'Token ${auth.token}',
'User-Agent': 'wger Workout Manager App',
diff --git a/lib/providers/helpers.dart b/lib/providers/helpers.dart
index 4ddf5d401..b792a60fc 100644
--- a/lib/providers/helpers.dart
+++ b/lib/providers/helpers.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
diff --git a/lib/providers/nutrition.dart b/lib/providers/nutrition.dart
index 7b1173359..334e2101d 100644
--- a/lib/providers/nutrition.dart
+++ b/lib/providers/nutrition.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:convert';
@@ -118,7 +118,7 @@ class Nutrition extends WgerBaseProvider with ChangeNotifier {
return plan;
}
- Future postPlan(NutritionalPlan planData) async {
+ Future addPlan(NutritionalPlan planData) async {
final data = await post(planData.toJson(), makeUrl(_nutritionalPlansPath));
final plan = NutritionalPlan.fromJson(data);
_plans.add(plan);
@@ -127,7 +127,7 @@ class Nutrition extends WgerBaseProvider with ChangeNotifier {
return plan;
}
- Future patchPlan(NutritionalPlan plan) async {
+ Future editPlan(NutritionalPlan plan) async {
await patch(plan.toJson(), makeUrl(_nutritionalPlansPath, id: plan.id));
notifyListeners();
}
@@ -268,14 +268,17 @@ class Nutrition extends WgerBaseProvider with ChangeNotifier {
}
/// Searches for an ingredient
- Future searchIngredient(String name) async {
+ Future searchIngredient(String name, [String languageCode = 'en']) async {
if (name.length <= 1) {
return [];
}
// Send the request
final response = await client.get(
- makeUrl(_ingredientSearchPath, query: {'term': name}),
+ makeUrl(
+ _ingredientSearchPath,
+ query: {'term': name, 'language': languageCode},
+ ),
headers: {
HttpHeaders.authorizationHeader: 'Token ${auth.token}',
HttpHeaders.userAgentHeader: 'wger Workout Manager App',
diff --git a/lib/providers/workout_plans.dart b/lib/providers/workout_plans.dart
index e663fb1b2..4c7fa532a 100644
--- a/lib/providers/workout_plans.dart
+++ b/lib/providers/workout_plans.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:convert';
@@ -140,6 +140,7 @@ class WorkoutPlans extends WgerBaseProvider with ChangeNotifier {
final setData = await fetch(makeUrl(_setsUrlPath, query: {'exerciseday': day.id.toString()}));
for (final setEntry in setData['results']) {
final workoutSet = Set.fromJson(setEntry);
+ fetchComputedSettings(workoutSet);
// Settings
List settings = [];
@@ -159,7 +160,7 @@ class WorkoutPlans extends WgerBaseProvider with ChangeNotifier {
if (!workoutSet.exercisesIds.contains(workoutSetting.exerciseId)) {
workoutSet.addExercise(workoutSetting.exerciseObj);
}
- workoutSetting.repsText = 'FIXME!';
+ workoutSetting.repsText = await fetchSmartText(workoutSet, workoutSetting.exerciseObj);
settings.add(workoutSetting);
}
workoutSet.settings = settings;
@@ -173,7 +174,12 @@ class WorkoutPlans extends WgerBaseProvider with ChangeNotifier {
// Logs
final logData = await fetch(makeUrl(_logsUrlPath, query: {'workout': workoutId.toString()}));
for (final entry in logData['results']) {
- plan.logs.add(Log.fromJson(entry));
+ var log = Log.fromJson(entry);
+ log.weightUnit = _weightUnits.firstWhere((e) => e.id == log.weightUnitId);
+ log.repetitionUnit = _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId);
+ log.exercise = _exercises.findById(log.exerciseId);
+
+ plan.logs.add(log);
}
// ... and done
@@ -182,19 +188,7 @@ class WorkoutPlans extends WgerBaseProvider with ChangeNotifier {
notifyListeners();
}
- Future fetchAndSetWorkouts() async {
- final data = await fetch(makeUrl(_workoutPlansUrlPath, query: {'ordering': '-creation_date'}));
- final List loadedWorkoutPlans = [];
-
- for (final entry in data['results']) {
- loadedWorkoutPlans.add(WorkoutPlan.fromJson(entry));
- }
-
- _workoutPlans = loadedWorkoutPlans;
- notifyListeners();
- }
-
- Future postWorkout(WorkoutPlan workout) async {
+ Future addWorkout(WorkoutPlan workout) async {
final data = await post(workout.toJson(), makeUrl(_workoutPlansUrlPath));
final plan = WorkoutPlan.fromJson(data);
_workoutPlans.insert(0, plan);
@@ -202,12 +196,9 @@ class WorkoutPlans extends WgerBaseProvider with ChangeNotifier {
return plan;
}
- Future patchWorkout(WorkoutPlan workout) async {
- final data = await patch(workout.toJson(), makeUrl(_workoutPlansUrlPath, id: workout.id));
- final plan = WorkoutPlan.fromJson(data);
- _workoutPlans[findIndexById(plan.id!)] = plan;
+ Future editWorkout(WorkoutPlan workout) async {
+ await patch(workout.toJson(), makeUrl(_workoutPlansUrlPath, id: workout.id));
notifyListeners();
- return plan;
}
Future deleteWorkout(int id) async {
@@ -329,6 +320,43 @@ class WorkoutPlans extends WgerBaseProvider with ChangeNotifier {
return set;
}
+ Future fetchComputedSettings(Set workoutSet) async {
+ final data = await fetch(makeUrl(
+ _setsUrlPath,
+ id: workoutSet.id!,
+ objectMethod: 'computed_settings',
+ ));
+
+ List settings = [];
+ data['results'].forEach((e) {
+ Setting workoutSetting = Setting.fromJson(e);
+
+ workoutSetting.weightUnitObj = _weightUnits.firstWhere(
+ (unit) => unit.id == workoutSetting.weightUnitId,
+ );
+ workoutSetting.repetitionUnitObj = _repetitionUnit.firstWhere(
+ (unit) => unit.id == workoutSetting.repetitionUnitId,
+ );
+ settings.add(workoutSetting);
+ });
+
+ workoutSet.settingsComputed = settings;
+ notifyListeners();
+ }
+
+ Future fetchSmartText(Set workoutSet, Exercise exercise) async {
+ final data = await fetch(
+ makeUrl(
+ _setsUrlPath,
+ id: workoutSet.id!,
+ objectMethod: 'smart_text',
+ query: {'exercise': exercise.id.toString()},
+ ),
+ );
+
+ return data['results'];
+ }
+
Future deleteSet(Set workoutSet) async {
await deleteRequest(_setsUrlPath, workoutSet.id!);
@@ -373,6 +401,14 @@ class WorkoutPlans extends WgerBaseProvider with ChangeNotifier {
Future addLog(Log log) async {
final data = await post(log.toJson(), makeUrl(_logsUrlPath));
final newLog = Log.fromJson(data);
+
+ log.id = newLog.id;
+ log.weightUnit = _weightUnits.firstWhere((e) => e.id == log.weightUnitId);
+ log.repetitionUnit = _repetitionUnit.firstWhere((e) => e.id == log.weightUnitId);
+ log.exercise = _exercises.findById(log.exerciseId);
+
+ final plan = findById(log.workoutPlan);
+ plan.logs.add(log);
notifyListeners();
return newLog;
}
diff --git a/lib/screens/auth_screen.dart b/lib/screens/auth_screen.dart
index 7ab6e746d..7fc03f680 100644
--- a/lib/screens/auth_screen.dart
+++ b/lib/screens/auth_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -36,8 +36,6 @@ class AuthScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final deviceSize = MediaQuery.of(context).size;
- // final transformConfig = Matrix4.rotationZ(-8 * pi / 180);
- // transformConfig.translate(-10.0);
return Scaffold(
backgroundColor: Theme.of(context).primaryColor,
body: Stack(
@@ -58,7 +56,6 @@ class AuthScreen extends StatelessWidget {
Container(
margin: EdgeInsets.only(bottom: 20.0),
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 94.0),
- // ..translate(-10.0),
child: Text(
'WGER',
style: TextStyle(
@@ -101,8 +98,8 @@ class _AuthCardState extends State {
'serverUrl': '',
};
var _isLoading = false;
- final _usernameController = TextEditingController(text: 'admin');
- final _passwordController = TextEditingController(text: 'adminadmin');
+ final _usernameController = TextEditingController();
+ final _passwordController = TextEditingController();
final _password2Controller = TextEditingController();
final _emailController = TextEditingController();
final _serverUrlController = TextEditingController(text: DEFAULT_SERVER);
@@ -175,10 +172,6 @@ class _AuthCardState extends State {
),
elevation: 8.0,
child: Container(
- //decoration: BoxDecoration(color: Colors.black12),
- //height: _authMode == AuthMode.Signup ? 450 : 320,
- //constraints:
- // BoxConstraints(minHeight: _authMode == AuthMode.Signup ? 450 : 320),
width: deviceSize.width * 0.75,
padding: EdgeInsets.all(16.0),
child: Form(
diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart
index f08c51247..8c4661dbc 100644
--- a/lib/screens/dashboard.dart
+++ b/lib/screens/dashboard.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/cupertino.dart';
@@ -70,8 +70,6 @@ class _DashboardScreenState extends State {
// Workouts
await Provider.of(context, listen: false).fetchAndSetUnits();
await Provider.of(context, listen: false).fetchAndSetAllPlans();
- //await Provider.of(context, listen: false).fetchAndSetWorkouts();
- //await Provider.of(context, listen: false).setAllFullWorkouts();
if (Provider.of(context, listen: false).activePlan != null) {
Provider.of(context, listen: false).setCurrentPlan(
Provider.of(context, listen: false).activePlan!.id!,
diff --git a/lib/screens/form_screen.dart b/lib/screens/form_screen.dart
index dc9f70c71..7b092099e 100644
--- a/lib/screens/form_screen.dart
+++ b/lib/screens/form_screen.dart
@@ -1,20 +1,21 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
+
import 'package:flutter/material.dart';
/// Arguments passed to the form screen
diff --git a/lib/screens/gym_mode.dart b/lib/screens/gym_mode.dart
index 2959fdab1..0a33d9453 100644
--- a/lib/screens/gym_mode.dart
+++ b/lib/screens/gym_mode.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -22,21 +22,22 @@ import 'package:wger/models/workouts/day.dart';
import 'package:wger/providers/workout_plans.dart';
import 'package:wger/widgets/workouts/gym_mode.dart';
-class GymModeScreen extends StatefulWidget {
+class GymModeScreen extends StatelessWidget {
static const routeName = '/gym-mode';
- @override
- _GymModeScreenState createState() => _GymModeScreenState();
-}
-
-class _GymModeScreenState extends State {
@override
Widget build(BuildContext context) {
final _day = ModalRoute.of(context)!.settings.arguments as Day;
return Scaffold(
- body: Consumer(
- builder: (context, value, child) => GymMode(_day),
+ backgroundColor: Colors.white,
+ body: SafeArea(
+ child: Consumer(
+ builder: (context, value, child) => Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
+ child: GymMode(_day),
+ ),
+ ),
),
);
}
diff --git a/lib/screens/home_tabs_screen.dart b/lib/screens/home_tabs_screen.dart
index 3d03b2e7c..674b6853b 100644
--- a/lib/screens/home_tabs_screen.dart
+++ b/lib/screens/home_tabs_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
- * wger Workout Manager is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/lib/screens/nutritional_plan_screen.dart b/lib/screens/nutritional_plan_screen.dart
index 64d828685..e878d8984 100644
--- a/lib/screens/nutritional_plan_screen.dart
+++ b/lib/screens/nutritional_plan_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -25,6 +25,8 @@ import 'package:wger/screens/form_screen.dart';
import 'package:wger/widgets/nutrition/forms.dart';
import 'package:wger/widgets/nutrition/nutritional_plan_detail.dart';
+import 'nutritional_plans_screen.dart';
+
enum NutritionalPlanOptions {
edit,
delete,
@@ -36,7 +38,7 @@ class NutritionalPlanScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final _nutritionalPlan = ModalRoute.of(context)!.settings.arguments as NutritionalPlan /*!*/;
+ final _nutritionalPlan = ModalRoute.of(context)!.settings.arguments as NutritionalPlan;
return Scaffold(
//appBar: getAppBar(nutritionalPlan),
@@ -66,7 +68,7 @@ class NutritionalPlanScreen extends StatelessWidget {
} else if (value == NutritionalPlanOptions.delete) {
Provider.of(context, listen: false)
.deletePlan(_nutritionalPlan.id!);
- Navigator.of(context).pushNamed(NutritionalPlanScreen.routeName);
+ Navigator.of(context).pushReplacementNamed(NutritionScreen.routeName);
}
},
itemBuilder: (BuildContext context) {
diff --git a/lib/screens/nutritional_plans_screen.dart b/lib/screens/nutritional_plans_screen.dart
index 278604e1e..311440802 100644
--- a/lib/screens/nutritional_plans_screen.dart
+++ b/lib/screens/nutritional_plans_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart
index 78dab998e..8b00bcff5 100644
--- a/lib/screens/splash_screen.dart
+++ b/lib/screens/splash_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/lib/screens/weight_screen.dart b/lib/screens/weight_screen.dart
index 06cb9e801..b18c22423 100644
--- a/lib/screens/weight_screen.dart
+++ b/lib/screens/weight_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/lib/screens/workout_plan_screen.dart b/lib/screens/workout_plan_screen.dart
index 4b03f1b3d..592491f81 100644
--- a/lib/screens/workout_plan_screen.dart
+++ b/lib/screens/workout_plan_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -121,14 +121,14 @@ class _WorkoutPlanScreenState extends State {
itemBuilder: (BuildContext context) {
return [
PopupMenuItem(
- value: WorkoutOptions.edit,
- child: Text(AppLocalizations.of(context)!.edit),
+ child: _mode == WorkoutScreenMode.log
+ ? Text(AppLocalizations.of(context)!.labelWorkoutPlan)
+ : Text(AppLocalizations.of(context)!.labelWorkoutLogs),
+ value: WorkoutOptions.toggleMode,
),
PopupMenuItem(
- child: _mode == WorkoutScreenMode.log
- ? Text('Open workout')
- : Text('Open logs'),
- value: WorkoutOptions.toggleMode,
+ value: WorkoutOptions.edit,
+ child: Text(AppLocalizations.of(context)!.edit),
),
const PopupMenuDivider(),
PopupMenuItem(
diff --git a/lib/screens/workout_plans_screen.dart b/lib/screens/workout_plans_screen.dart
index b7ee37279..8fc20fb77 100644
--- a/lib/screens/workout_plans_screen.dart
+++ b/lib/screens/workout_plans_screen.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/cupertino.dart';
diff --git a/lib/theme/theme.dart b/lib/theme/theme.dart
index 8a9270c5f..b91abbb12 100644
--- a/lib/theme/theme.dart
+++ b/lib/theme/theme.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:charts_flutter/flutter.dart' as charts;
@@ -30,6 +30,17 @@ const Color wgerBackground = Color(0xfff4f4f6);
const charts.Color wgerChartPrimaryColor = charts.Color(r: 0x2a, g: 0x4c, b: 0x7d);
const charts.Color wgerChartSecondaryColor = charts.Color(r: 0xe6, g: 0x39, b: 0x46);
+/// Original sizes for the material text theme
+/// https://api.flutter.dev/flutter/material/TextTheme-class.html
+const materialSizes = {
+ 'h1': 96.0,
+ 'h2': 60.0,
+ 'h3': 48.0,
+ 'h4': 34.0,
+ 'h5': 24.0,
+ 'h6': 20.0,
+};
+
final ThemeData wgerTheme = ThemeData(
/*
* General stuff
@@ -47,12 +58,28 @@ final ThemeData wgerTheme = ThemeData(
* Text theme
*/
textTheme: TextTheme(
- //headline1: TextStyle(fontSize: 30.0, fontFamily: "OpenSansBold"),
- //headline2: TextStyle(fontSize: 30.0, fontFamily: "OpenSansBold"),
- headline4: TextStyle(fontSize: 27.0, fontFamily: "OpenSansBold", color: Colors.black),
- headline5: TextStyle(fontSize: 25.0, fontFamily: "OpenSansBold", color: Colors.black),
- headline6: TextStyle(fontSize: 20.0, fontFamily: "OpenSansBold", color: Colors.black),
- //headline6: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
+ headline1: TextStyle(fontFamily: "OpenSansLight", color: Colors.black),
+ headline2: TextStyle(fontFamily: "OpenSansLight", color: Colors.black),
+ headline3: TextStyle(
+ fontSize: materialSizes['h3']! * 0.8,
+ fontFamily: "OpenSansBold",
+ color: Colors.black,
+ ),
+ headline4: TextStyle(
+ fontSize: materialSizes['h4']! * 0.8,
+ fontFamily: "OpenSansBold",
+ color: Colors.black,
+ ),
+ headline5: TextStyle(
+ fontSize: materialSizes['h5']!,
+ fontFamily: "OpenSansBold",
+ color: Colors.black,
+ ),
+ headline6: TextStyle(
+ fontSize: materialSizes['h6']! * 0.8,
+ fontFamily: "OpenSansBold",
+ color: Colors.black,
+ ),
),
/*
diff --git a/lib/widgets/app_drawer.dart b/lib/widgets/app_drawer.dart
index 4c0d6e438..0e7bd7dd4 100644
--- a/lib/widgets/app_drawer.dart
+++ b/lib/widgets/app_drawer.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/gestures.dart';
@@ -103,7 +103,7 @@ class AppDrawer extends StatelessWidget {
ListTile(
//dense: true,
leading: Icon(Icons.exit_to_app),
- title: Text('Logout'),
+ title: Text(AppLocalizations.of(context)!.logout),
onTap: () {
Provider.of(context, listen: false).logout();
Navigator.of(context).pop();
diff --git a/lib/widgets/core/core.dart b/lib/widgets/core/core.dart
index ee041f5ec..8a8382412 100644
--- a/lib/widgets/core/core.dart
+++ b/lib/widgets/core/core.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
diff --git a/lib/widgets/dashboard/calendar.dart b/lib/widgets/dashboard/calendar.dart
index a710f47f7..9eaeab26e 100644
--- a/lib/widgets/dashboard/calendar.dart
+++ b/lib/widgets/dashboard/calendar.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
import 'dart:developer';
@@ -372,21 +372,6 @@ class _DashboardCalendarWidgetState extends State
),
],
);
-
- return Column(
- children: [
- TextButton(
- child: Text('Go to today'),
- onPressed: () {
- final today = DateTime.now();
- _calendarController.setSelectedDay(
- DateTime(today.year, today.month, today.day),
- runCallback: true,
- );
- },
- ),
- ],
- );
}
Widget _buildEventList() {
diff --git a/lib/widgets/dashboard/widgets.dart b/lib/widgets/dashboard/widgets.dart
index 788772ca8..41bd1cc93 100644
--- a/lib/widgets/dashboard/widgets.dart
+++ b/lib/widgets/dashboard/widgets.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
@@ -27,6 +27,7 @@ import 'package:wger/providers/body_weight.dart';
import 'package:wger/providers/nutrition.dart';
import 'package:wger/providers/workout_plans.dart';
import 'package:wger/screens/form_screen.dart';
+import 'package:wger/screens/gym_mode.dart';
import 'package:wger/screens/nutritional_plan_screen.dart';
import 'package:wger/screens/workout_plan_screen.dart';
import 'package:wger/theme/theme.dart';
@@ -254,11 +255,17 @@ class _DashboardWorkoutWidgetState extends State {
day.description,
style: TextStyle(fontWeight: FontWeight.bold),
));
+ out.add(IconButton(
+ icon: Icon(Icons.play_arrow),
+ onPressed: () {
+ Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: day);
+ },
+ ));
if (showDetail) {
day.sets.forEach((set) {
out.add(Column(
children: [
- ...set.settings.map((s) {
+ ...set.settingsFiltered.map((s) {
return Column(
children: [
Text(s.exerciseObj.name),
@@ -267,7 +274,7 @@ class _DashboardWorkoutWidgetState extends State {
],
);
}).toList(),
- SizedBox(height: 7),
+ SizedBox(height: 15),
],
));
});
diff --git a/lib/widgets/nutrition/charts.dart b/lib/widgets/nutrition/charts.dart
index 3a072fa58..cf8adc7f7 100644
--- a/lib/widgets/nutrition/charts.dart
+++ b/lib/widgets/nutrition/charts.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
@@ -50,7 +50,7 @@ class NutritionalPlanPieChartWidget extends StatelessWidget {
[AppLocalizations.of(context)!.carbohydrates, _nutritionalValues.carbohydrates],
],
labelAccessorFn: (List row, _) =>
- '${row[0]}, ${row[1].toStringAsFixed(0)}${AppLocalizations.of(context)!.g}',
+ '${row[0]}\n${row[1].toStringAsFixed(0)}${AppLocalizations.of(context)!.g}',
)
],
defaultRenderer: new charts.ArcRendererConfig(
diff --git a/lib/widgets/nutrition/forms.dart b/lib/widgets/nutrition/forms.dart
index b1f876304..1071e276c 100644
--- a/lib/widgets/nutrition/forms.dart
+++ b/lib/widgets/nutrition/forms.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
@@ -27,11 +27,11 @@ import 'package:wger/models/nutrition/meal.dart';
import 'package:wger/models/nutrition/meal_item.dart';
import 'package:wger/models/nutrition/nutritional_plan.dart';
import 'package:wger/providers/nutrition.dart';
+import 'package:wger/screens/nutritional_plan_screen.dart';
class MealForm extends StatelessWidget {
late Meal _meal;
int _planId;
- //var _mealData = {'id': null, 'planId': -1, 'time': TimeOfDay.now()};
final _form = GlobalKey();
final _timeController = TextEditingController();
@@ -41,19 +41,6 @@ class MealForm extends StatelessWidget {
_timeController.text = timeToString(_meal.time)!;
}
- /*
- MealForm(int planId, [Meal? meal]) {
- _mealData['planId'] = planId;
- _timeController.text = timeToString(_mealData['time'] as TimeOfDay)!;
-
- if (meal != null) {
- _mealData['id'] = meal.id;
- _mealData['time'] = meal.time;
- _timeController.text = timeToString(meal.time)!;
- }
- }
- */
-
@override
Widget build(BuildContext context) {
return Container(
@@ -114,8 +101,8 @@ class MealItemForm extends StatelessWidget {
late MealItem _mealItem;
MealItemForm(this._meal, [mealItem]) {
- this._mealItem = mealItem;
- //this._mealItem = mealItem ?? MealItem(mealId: _meal.id);
+ this._mealItem = mealItem ?? MealItem.empty();
+ _mealItem.mealId = _meal.id!;
}
final _form = GlobalKey();
@@ -136,8 +123,10 @@ class MealItemForm extends StatelessWidget {
decoration: InputDecoration(labelText: AppLocalizations.of(context)!.ingredient),
),
suggestionsCallback: (pattern) async {
- return await Provider.of(context, listen: false)
- .searchIngredient(pattern);
+ return await Provider.of(context, listen: false).searchIngredient(
+ pattern,
+ Localizations.localeOf(context).languageCode,
+ );
},
itemBuilder: (context, dynamic suggestion) {
return ListTile(
@@ -156,14 +145,11 @@ class MealItemForm extends StatelessWidget {
if (value!.isEmpty) {
return AppLocalizations.of(context)!.selectIngredient;
}
- if (_mealItem.ingredientId == null) {
- return AppLocalizations.of(context)!.selectIngredient;
- }
return null;
},
),
TextFormField(
- decoration: InputDecoration(labelText: AppLocalizations.of(context)!.amount),
+ decoration: InputDecoration(labelText: AppLocalizations.of(context)!.weight),
controller: _amountController,
keyboardType: TextInputType.number,
onFieldSubmitted: (_) {},
@@ -205,24 +191,13 @@ class MealItemForm extends StatelessWidget {
}
class PlanForm extends StatelessWidget {
- //NutritionalPlan? _plan;
- var _planData = {
- 'description': '',
- 'creationDate': DateTime.now(),
- 'id': null,
- };
-
final _form = GlobalKey();
final _descriptionController = TextEditingController();
+ late NutritionalPlan _plan;
PlanForm([NutritionalPlan? plan]) {
- if (plan != null) {
- _planData['id'] = plan.id;
- _planData['description'] = plan.description;
- _planData['creationDate'] = plan.creationDate;
- }
-
- _descriptionController.text = _planData['description'] as String;
+ _plan = plan != null ? plan : NutritionalPlan.empty();
+ _descriptionController.text = _plan.description;
}
@override
@@ -237,7 +212,7 @@ class PlanForm extends StatelessWidget {
controller: _descriptionController,
onFieldSubmitted: (_) {},
onSaved: (newValue) {
- _planData['description'] = newValue!;
+ _plan.description = newValue!;
},
),
ElevatedButton(
@@ -252,27 +227,21 @@ class PlanForm extends StatelessWidget {
// Save the entry on the server
try {
- NutritionalPlan plan = NutritionalPlan(
- description: _planData['description'] as String,
- creationDate: _planData['creationDate'] as DateTime,
- );
-
- if (_planData['id'] != null) {
- plan.id = _planData['id'] as int;
- await Provider.of(context, listen: false).patchPlan(plan);
- } else {
- await Provider.of(context, listen: false).postPlan(plan);
- }
+ _plan.id != null
+ ? await Provider.of(context, listen: false).editPlan(_plan)
+ : _plan = await Provider.of(context, listen: false).addPlan(_plan);
// Saving was successful, reset the data
- //descriptionController.clear();
- //nutritionalPlan = NutritionalPlan();
+ _descriptionController.clear();
} on WgerHttpException catch (error) {
showHttpExceptionErrorDialog(error, context);
} catch (error) {
showErrorDialog(error, context);
}
- Navigator.of(context).pop();
+ Navigator.of(context).pushReplacementNamed(
+ NutritionalPlanScreen.routeName,
+ arguments: _plan,
+ );
},
),
],
diff --git a/lib/widgets/nutrition/meal.dart b/lib/widgets/nutrition/meal.dart
index a35e32715..55e56c370 100644
--- a/lib/widgets/nutrition/meal.dart
+++ b/lib/widgets/nutrition/meal.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
@@ -100,7 +100,7 @@ class MealItemWidget extends StatelessWidget {
Widget build(BuildContext context) {
String unit = _item.weightUnitId == null
? AppLocalizations.of(context)!.g
- : _item.weightUnitObj.weightUnit.name;
+ : _item.weightUnitObj!.weightUnit.name;
final values = _item.nutritionalValues;
return Container(
@@ -127,7 +127,7 @@ class MealItemWidget extends StatelessWidget {
Provider.of(context, listen: false).deleteMealItem(_item);
// and inform the user
- Scaffold.of(context).showSnackBar(
+ ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.of(context)!.successfullyDeleted,
@@ -244,7 +244,7 @@ class DismissibleMealHeader extends StatelessWidget {
Provider.of(context, listen: false).deleteMeal(_meal);
// and inform the user
- Scaffold.of(context).showSnackBar(
+ ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.of(context)!.successfullyDeleted,
@@ -256,7 +256,7 @@ class DismissibleMealHeader extends StatelessWidget {
// Log meal
} else {
Provider.of(context, listen: false).logMealToDiary(_meal);
- Scaffold.of(context).showSnackBar(
+ ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.of(context)!.mealLogged,
diff --git a/lib/widgets/nutrition/nutritional_plan_detail.dart b/lib/widgets/nutrition/nutritional_plan_detail.dart
index b1e2a62c8..bee910c18 100644
--- a/lib/widgets/nutrition/nutritional_plan_detail.dart
+++ b/lib/widgets/nutrition/nutritional_plan_detail.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
@@ -114,7 +114,10 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
),
),
Padding(padding: const EdgeInsets.all(8.0)),
- Text('Diary', style: Theme.of(context).textTheme.headline6),
+ Text(
+ AppLocalizations.of(context)!.nutritionalDiary,
+ style: Theme.of(context).textTheme.headline6,
+ ),
Container(
padding: EdgeInsets.all(15),
height: 220,
@@ -122,37 +125,35 @@ class NutritionalPlanDetailWidget extends StatelessWidget {
),
Container(
height: 200,
- child: SingleChildScrollView(
+ child: ListView(
scrollDirection: Axis.horizontal,
- child: Row(
- children: [
- Padding(
- padding: const EdgeInsets.all(8),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(''),
- Text(
- '${AppLocalizations.of(context)!.energy} (${AppLocalizations.of(context)!.kcal})'),
- Text(
- '${AppLocalizations.of(context)!.protein} (${AppLocalizations.of(context)!.g})'),
- Text(
- '${AppLocalizations.of(context)!.carbohydrates} (${AppLocalizations.of(context)!.g})'),
- Text(
- '${AppLocalizations.of(context)!.sugars} (${AppLocalizations.of(context)!.g})'),
- Text(
- '${AppLocalizations.of(context)!.fat} (${AppLocalizations.of(context)!.g})'),
- Text(
- '${AppLocalizations.of(context)!.saturatedFat} (${AppLocalizations.of(context)!.g})'),
- ],
- ),
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(8),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Text(''),
+ Text(
+ '${AppLocalizations.of(context)!.energy} (${AppLocalizations.of(context)!.kcal})'),
+ Text(
+ '${AppLocalizations.of(context)!.protein} (${AppLocalizations.of(context)!.g})'),
+ Text(
+ '${AppLocalizations.of(context)!.carbohydrates} (${AppLocalizations.of(context)!.g})'),
+ Text(
+ '${AppLocalizations.of(context)!.sugars} (${AppLocalizations.of(context)!.g})'),
+ Text(
+ '${AppLocalizations.of(context)!.fat} (${AppLocalizations.of(context)!.g})'),
+ Text(
+ '${AppLocalizations.of(context)!.saturatedFat} (${AppLocalizations.of(context)!.g})'),
+ ],
),
- ..._nutritionalPlan.logEntriesValues.entries
- .map((entry) => NutritionDiaryEntry(entry.key, entry.value))
- .toList()
- .reversed,
- ],
- ),
+ ),
+ ..._nutritionalPlan.logEntriesValues.entries
+ .map((entry) => NutritionDiaryEntry(entry.key, entry.value))
+ .toList()
+ .reversed,
+ ],
),
),
],
@@ -177,8 +178,10 @@ class NutritionDiaryEntry extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
- Text(DateFormat.yMd().format(date).toString(),
- style: TextStyle(fontWeight: FontWeight.bold)),
+ Text(
+ DateFormat.yMd(Localizations.localeOf(context).languageCode).format(date),
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
Text(values.energy.toStringAsFixed(0)),
Text(values.protein.toStringAsFixed(0)),
Text(values.carbohydrates.toStringAsFixed(0)),
diff --git a/lib/widgets/nutrition/nutritional_plans_list.dart b/lib/widgets/nutrition/nutritional_plans_list.dart
index a57502d08..88d70821d 100644
--- a/lib/widgets/nutrition/nutritional_plans_list.dart
+++ b/lib/widgets/nutrition/nutritional_plans_list.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -62,7 +62,7 @@ class NutritionalPlansList extends StatelessWidget {
Navigator.of(contextDialog).pop();
// and inform the user
- Scaffold.of(context).showSnackBar(
+ ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.of(context)!.successfullyDeleted,
diff --git a/lib/widgets/weight/charts.dart b/lib/widgets/weight/charts.dart
index 66e1031d3..4ccfa9d96 100644
--- a/lib/widgets/weight/charts.dart
+++ b/lib/widgets/weight/charts.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
diff --git a/lib/widgets/weight/entries_list.dart b/lib/widgets/weight/entries_list.dart
index 70fa1929d..5b21e6a64 100644
--- a/lib/widgets/weight/entries_list.dart
+++ b/lib/widgets/weight/entries_list.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -52,10 +52,10 @@ class WeightEntriesList extends StatelessWidget {
_weightProvider.deleteEntry(currentEntry.id!);
// and inform the user
- Scaffold.of(context).showSnackBar(
+ ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
- "Deleted weight entry for the ${DateFormat.yMd().format(currentEntry.date).toString()}",
+ AppLocalizations.of(context)!.successfullyDeleted,
textAlign: TextAlign.center,
),
),
diff --git a/lib/widgets/weight/forms.dart b/lib/widgets/weight/forms.dart
index 12c56f926..f8f6c0781 100644
--- a/lib/widgets/weight/forms.dart
+++ b/lib/widgets/weight/forms.dart
@@ -1,3 +1,21 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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.
+ *
+ * wger Workout Manager 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 .
+ */
+
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@@ -10,14 +28,15 @@ import 'package:wger/providers/body_weight.dart';
class WeightForm extends StatelessWidget {
final _form = GlobalKey();
- final dateController = TextEditingController(text: toDate(DateTime.now()).toString());
+ final dateController = TextEditingController();
final weightController = TextEditingController();
late WeightEntry _weightEntry;
WeightForm([WeightEntry? weightEntry]) {
- this._weightEntry = weightEntry ?? WeightEntry();
+ this._weightEntry = weightEntry ?? WeightEntry(date: DateTime.now());
weightController.text = _weightEntry.id == null ? '' : _weightEntry.weight.toString();
+ dateController.text = toDate(_weightEntry.date)!;
}
@override
@@ -37,9 +56,20 @@ class WeightForm extends StatelessWidget {
// Show Date Picker Here
var pickedDate = await showDatePicker(
context: context,
- initialDate: DateTime.now(),
+ initialDate: _weightEntry.date,
firstDate: DateTime(DateTime.now().year - 10),
lastDate: DateTime.now(),
+ selectableDayPredicate: (day) {
+ // Always allow the current initial date
+ if (day == _weightEntry.date) {
+ return true;
+ }
+
+ // if the date is known, don't allow it
+ return Provider.of(context, listen: false).findByDate(day) == null
+ ? true
+ : false;
+ },
);
dateController.text = toDate(pickedDate)!;
@@ -47,7 +77,6 @@ class WeightForm extends StatelessWidget {
onSaved: (newValue) {
_weightEntry.date = DateTime.parse(newValue!);
},
- onFieldSubmitted: (_) {},
),
// Weight
@@ -55,7 +84,6 @@ class WeightForm extends StatelessWidget {
decoration: InputDecoration(labelText: AppLocalizations.of(context)!.weight),
controller: weightController,
keyboardType: TextInputType.number,
- onFieldSubmitted: (_) {},
onSaved: (newValue) {
_weightEntry.weight = double.parse(newValue!);
},
diff --git a/lib/widgets/workouts/charts.dart b/lib/widgets/workouts/charts.dart
index 0991d6bfd..f9316f89b 100644
--- a/lib/widgets/workouts/charts.dart
+++ b/lib/widgets/workouts/charts.dart
@@ -1,20 +1,21 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
+
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:flutter/widgets.dart';
@@ -32,28 +33,30 @@ class LogChartWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return charts.TimeSeriesChart(
- [
- ..._data['chart_data'].map((e) {
- return charts.Series(
- id: '${e.first['reps']} reps',
- domainFn: (datum, index) => datum.time,
- measureFn: (datum, index) => datum.weight,
- data: [
- ...e.map(
- (entry) => TimeSeriesLog(
- DateTime.parse(entry['date']),
- double.parse(entry['weight']),
- ),
- ),
+ return _data.containsKey('chart_data') && _data['chart_data'].length > 0
+ ? charts.TimeSeriesChart(
+ [
+ ..._data['chart_data'].map((e) {
+ return charts.Series(
+ id: '${e.first['reps']} reps',
+ domainFn: (datum, index) => datum.time,
+ measureFn: (datum, index) => datum.weight,
+ data: [
+ ...e.map(
+ (entry) => TimeSeriesLog(
+ DateTime.parse(entry['date']),
+ double.parse(entry['weight']),
+ ),
+ ),
+ ],
+ );
+ }),
],
- );
- }),
- ],
- primaryMeasureAxis: new charts.NumericAxisSpec(
- tickProviderSpec: new charts.BasicNumericTickProviderSpec(zeroBound: false),
- ),
- //behaviors: [new charts.SeriesLegend()],
- );
+ primaryMeasureAxis: new charts.NumericAxisSpec(
+ tickProviderSpec: new charts.BasicNumericTickProviderSpec(zeroBound: false),
+ ),
+ //behaviors: [new charts.SeriesLegend()],
+ )
+ : Container();
}
}
diff --git a/lib/widgets/workouts/day.dart b/lib/widgets/workouts/day.dart
index 29f8a383d..3c09a5392 100644
--- a/lib/widgets/workouts/day.dart
+++ b/lib/widgets/workouts/day.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -75,7 +75,7 @@ class _WorkoutDayWidgetState extends State {
Expanded(
child: Column(
children: [
- ...set.settings
+ ...set.settingsFiltered
.map(
(setting) => SettingWidget(
setting: setting,
diff --git a/lib/widgets/workouts/exercises.dart b/lib/widgets/workouts/exercises.dart
index fbc075ca2..56b055e0e 100644
--- a/lib/widgets/workouts/exercises.dart
+++ b/lib/widgets/workouts/exercises.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
diff --git a/lib/widgets/workouts/forms.dart b/lib/widgets/workouts/forms.dart
index b824b4033..1061b8ef5 100644
--- a/lib/widgets/workouts/forms.dart
+++ b/lib/widgets/workouts/forms.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
@@ -27,7 +27,6 @@ import 'package:wger/models/workouts/set.dart';
import 'package:wger/models/workouts/setting.dart';
import 'package:wger/models/workouts/weight_unit.dart';
import 'package:wger/models/workouts/workout_plan.dart';
-import 'package:wger/providers/auth.dart';
import 'package:wger/providers/exercises.dart';
import 'package:wger/providers/workout_plans.dart';
import 'package:wger/screens/workout_plan_screen.dart';
@@ -78,14 +77,15 @@ class WorkoutForm extends StatelessWidget {
_form.currentState!.save();
// Save to DB
- final workout = _plan.id != null
- ? await Provider.of(context, listen: false).patchWorkout(_plan)
- : await Provider.of(context, listen: false).postWorkout(_plan);
+ _plan.id != null
+ ? await Provider.of(context, listen: false).editWorkout(_plan)
+ : _plan =
+ await Provider.of(context, listen: false).addWorkout(_plan);
- Navigator.of(context).pop();
- if (_plan.id == null) {
- Navigator.of(context).pushNamed(WorkoutPlanScreen.routeName, arguments: workout);
- }
+ Navigator.of(context).pushReplacementNamed(
+ WorkoutPlanScreen.routeName,
+ arguments: _plan,
+ );
},
),
],
@@ -144,67 +144,67 @@ class _DayFormWidgetState extends State {
@override
Widget build(BuildContext context) {
- return Container(
- margin: EdgeInsets.all(20),
- child: Form(
- key: _form,
- child: Column(
- children: [
- TextFormField(
- decoration: InputDecoration(labelText: AppLocalizations.of(context)!.description),
- controller: widget.dayController,
- onSaved: (value) {
- widget._day.description = value!;
- },
- validator: (value) {
- const minLength = 5;
- const maxLength = 100;
- if (value!.isEmpty || value.length < minLength || value.length > maxLength) {
- return AppLocalizations.of(context)!.enterCharacters(minLength, maxLength);
- }
- return null;
- },
+ return Form(
+ key: _form,
+ child: ListView(
+ children: [
+ TextFormField(
+ decoration: InputDecoration(
+ labelText: AppLocalizations.of(context)!.description,
+ helperText: AppLocalizations.of(context)!.dayDescriptionHelp,
+ helperMaxLines: 3,
),
- SizedBox(height: 10),
- Text('Week days'),
- ...Day.weekdays.keys.map((dayNr) => DayCheckbox(dayNr, widget._day)).toList(),
- ElevatedButton(
- child: Text(AppLocalizations.of(context)!.save),
- onPressed: () async {
- if (!_form.currentState!.validate()) {
- return;
- }
- _form.currentState!.save();
+ controller: widget.dayController,
+ onSaved: (value) {
+ widget._day.description = value!;
+ },
+ validator: (value) {
+ const minLength = 5;
+ const maxLength = 100;
+ if (value!.isEmpty || value.length < minLength || value.length > maxLength) {
+ return AppLocalizations.of(context)!.enterCharacters(minLength, maxLength);
+ }
+ return null;
+ },
+ ),
+ SizedBox(height: 10),
+ ...Day.weekdays.keys.map((dayNr) => DayCheckbox(dayNr, widget._day)).toList(),
+ ElevatedButton(
+ child: Text(AppLocalizations.of(context)!.save),
+ onPressed: () async {
+ if (!_form.currentState!.validate()) {
+ return;
+ }
+ _form.currentState!.save();
- try {
- Provider.of(context, listen: false).addDay(
- widget._day,
- widget.workout,
- );
+ try {
+ Provider.of(context, listen: false).addDay(
+ widget._day,
+ widget.workout,
+ );
- widget.dayController.clear();
- Navigator.of(context).pop();
- } catch (error) {
- await showDialog(
- context: context,
- builder: (ctx) => AlertDialog(
- title: Text('An error occurred!'),
- content: Text('Something went wrong.'),
- actions: [
- TextButton(
- child: Text('Okay'),
- onPressed: () {
- Navigator.of(ctx).pop();
- },
- )
- ],
- ),
- );
- }
- },
- ),
- ],
- ),
+ widget.dayController.clear();
+ Navigator.of(context).pop();
+ } catch (error) {
+ await showDialog(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ title: Text('An error occurred!'),
+ content: Text('Something went wrong.'),
+ actions: [
+ TextButton(
+ child: Text('Okay'),
+ onPressed: () {
+ Navigator.of(ctx).pop();
+ },
+ )
+ ],
+ ),
+ );
+ }
+ },
+ ),
+ ],
),
);
}
@@ -214,7 +214,7 @@ class SetFormWidget extends StatefulWidget {
Day _day;
late Set _set;
- SetFormWidget(Day this._day, [Set? set]) {
+ SetFormWidget(this._day, [Set? set]) {
this._set = set ?? Set.withData(day: _day.id, sets: 4);
}
@@ -254,13 +254,10 @@ class _SetFormWidgetState extends State {
for (int loop = 0; loop < widget._set.sets; loop++) {
Setting setting = Setting.empty();
setting.order = order;
- setting.setExercise(exercise);
- setting.setRepetitionUnit(
- Provider.of(context, listen: false).defaultRepetitionUnit,
- );
- setting.setWeightUnit(
- Provider.of(context, listen: false).defaultWeightUnit,
- );
+ setting.exercise = exercise;
+ setting.weightUnit = Provider.of(context, listen: false).defaultWeightUnit;
+ setting.repetitionUnit =
+ Provider.of(context, listen: false).defaultRepetitionUnit;
widget._set.settings.add(setting);
}
@@ -279,15 +276,18 @@ class _SetFormWidgetState extends State {
decoration: InputDecoration(
labelText: AppLocalizations.of(context)!.exercise,
helperMaxLines: 3,
+ errorMaxLines: 2,
helperText: AppLocalizations.of(context)!.selectExercises),
),
suggestionsCallback: (pattern) async {
- return await Provider.of(context, listen: false).searchExercise(pattern);
+ return await Provider.of(context, listen: false).searchExercise(
+ pattern,
+ Localizations.localeOf(context).languageCode,
+ );
},
itemBuilder: (context, suggestion) {
final result = suggestion! as Map;
- String serverUrl = Provider.of(context, listen: false).serverUrl!;
final exercise =
Provider.of(context, listen: false).findById(result['data']['id']);
return ListTile(
@@ -311,9 +311,16 @@ class _SetFormWidgetState extends State {
this._exercisesController.text = '';
},
validator: (value) {
+ // At least one exercise must be selected
if (widget._set.exercisesIds.length == 0) {
return AppLocalizations.of(context)!.selectExercise;
}
+
+ // At least one setting has to be filled in
+ if (widget._set.settings.where((s) => s.weight == null && s.reps == null).length ==
+ widget._set.settings.length) {
+ return AppLocalizations.of(context)!.enterRepetitionsOrWeight;
+ }
return null;
},
),
@@ -382,13 +389,17 @@ class _SetFormWidgetState extends State {
for (var setting in widget._set.settings) {
setting.setId = setDb.id!;
setting.comment = '';
- setting.repsText = 'temp text';
Setting settingDb = await workoutProvider.addSetting(setting);
+ setting.repsText = await workoutProvider.fetchSmartText(
+ widget._set,
+ setting.exerciseObj,
+ );
setting.id = settingDb.id;
}
// Add to workout day
+ workoutProvider.fetchComputedSettings(widget._set);
widget._day.sets.add(widget._set);
// Close the bottom sheet
@@ -546,9 +557,11 @@ class RepsInputWidget extends StatelessWidget {
}
return null;
},
- onSaved: (newValue) {
- if (newValue != null && newValue != '') {
- _setting.reps = int.parse(newValue);
+ onChanged: (newValue) {
+ if (newValue != '') {
+ try {
+ _setting.reps = int.parse(newValue);
+ } catch (e) {}
}
},
);
@@ -581,38 +594,46 @@ class WeightInputWidget extends StatelessWidget {
}
return null;
},
- onSaved: (newValue) {
- if (newValue != null && newValue != '') {
- _setting.weight = double.parse(newValue);
+ onChanged: (newValue) {
+ if (newValue != '') {
+ try {
+ _setting.weight = double.parse(newValue);
+ } catch (e) {}
}
},
);
}
}
+/// Input widget for Rests In Reserve
+///
+/// Can be used with a Setting or a Log object
class RiRInputWidget extends StatefulWidget {
- final Setting _setting;
- RiRInputWidget(this._setting);
+ final dynamic _setting;
+ late String dropdownValue;
+ RiRInputWidget(this._setting) {
+ dropdownValue = _setting.rir != null ? _setting.rir : Setting.DEFAULT_RIR;
+ }
@override
_RiRInputWidgetState createState() => _RiRInputWidgetState();
}
class _RiRInputWidgetState extends State {
- String dropdownValue = '1';
-
@override
Widget build(BuildContext context) {
return DropdownButtonFormField(
decoration: InputDecoration(labelText: AppLocalizations.of(context)!.rir),
- value: dropdownValue,
+ value: widget.dropdownValue,
+ onSaved: (String? newValue) {
+ widget._setting.setRir(newValue!);
+ },
onChanged: (String? newValue) {
setState(() {
- dropdownValue = newValue!;
- widget._setting.setRir(newValue);
+ widget.dropdownValue = newValue!;
});
},
- items: Setting.possibleValues.map>((String value) {
+ items: Setting.POSSIBLE_RIR_VALUES.map>((String value) {
return DropdownMenuItem(
value: value,
child: Text(value),
@@ -622,8 +643,11 @@ class _RiRInputWidgetState extends State {
}
}
+/// Input widget for workout weight units
+///
+/// Can be used with a Setting or a Log object
class WeightUnitInputWidget extends StatefulWidget {
- final Setting _setting;
+ final dynamic _setting;
WeightUnitInputWidget(this._setting, {Key? key}) : super(key: key);
@@ -642,7 +666,7 @@ class _WeightUnitInputWidgetState extends State {
onChanged: (WeightUnit? newValue) {
setState(() {
selectedWeightUnit = newValue!;
- widget._setting.setWeightUnit(newValue);
+ widget._setting.weightUnit = newValue;
});
},
items: Provider.of(context, listen: false)
@@ -657,8 +681,11 @@ class _WeightUnitInputWidgetState extends State {
}
}
+/// Input widget for repetition units
+///
+/// Can be used with a Setting or a Log object
class RepetitionUnitInputWidget extends StatefulWidget {
- final Setting _setting;
+ final dynamic _setting;
RepetitionUnitInputWidget(this._setting);
@override
@@ -677,7 +704,7 @@ class _RepetitionUnitInputWidgetState extends State {
onChanged: (RepetitionUnit? newValue) {
setState(() {
selectedWeightUnit = newValue!;
- widget._setting.setRepetitionUnit(newValue);
+ widget._setting.repetitionUnit = newValue;
});
},
items: Provider.of(context, listen: false)
diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart
index b9eeea0f6..0432c27af 100644
--- a/lib/widgets/workouts/gym_mode.dart
+++ b/lib/widgets/workouts/gym_mode.dart
@@ -1,27 +1,29 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+import 'package:flutter_html/flutter_html.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
+import 'package:wger/helpers/json.dart';
import 'package:wger/helpers/ui.dart';
import 'package:wger/models/exercises/exercise.dart';
import 'package:wger/models/http_exception.dart';
@@ -32,16 +34,25 @@ import 'package:wger/models/workouts/setting.dart';
import 'package:wger/models/workouts/workout_plan.dart';
import 'package:wger/providers/exercises.dart';
import 'package:wger/providers/workout_plans.dart';
+import 'package:wger/theme/theme.dart';
+import 'package:wger/widgets/workouts/exercises.dart';
+import 'package:wger/widgets/workouts/forms.dart';
class GymMode extends StatefulWidget {
final Day _workoutDay;
- GymMode(this._workoutDay);
+ late TimeOfDay _start;
+
+ GymMode(this._workoutDay) {
+ _start = TimeOfDay.now();
+ }
@override
_GymModeState createState() => _GymModeState();
}
class _GymModeState extends State {
+ var _totalElements = 1;
+
PageController _controller = PageController(
initialPage: 0,
);
@@ -52,27 +63,44 @@ class _GymModeState extends State {
super.dispose();
}
+ @override
+ void initState() {
+ super.initState();
+
+ // Calculate amount of elements for progress indicator
+ for (var set in widget._workoutDay.sets) {
+ _totalElements = _totalElements + set.settingsComputed.length;
+ }
+ }
+
@override
Widget build(BuildContext context) {
final exerciseProvider = Provider.of(context, listen: false);
final workoutProvider = Provider.of(context, listen: false);
-
+ var currentElement = 1;
List out = [];
+ // Build the list of exercise overview, sets and pause pages
for (var set in widget._workoutDay.sets) {
var firstPage = true;
for (var setting in set.settingsComputed) {
+ var ratioCompleted = currentElement / _totalElements;
+ currentElement++;
if (firstPage) {
- out.add(ExerciseOverview(_controller, exerciseProvider.findById(setting.exerciseId)));
+ out.add(ExerciseOverview(
+ _controller,
+ exerciseProvider.findById(setting.exerciseId),
+ ratioCompleted,
+ ));
}
out.add(LogPage(
_controller,
setting,
exerciseProvider.findById(setting.exerciseId),
workoutProvider.findById(widget._workoutDay.workoutId),
+ ratioCompleted,
));
- out.add(TimerWidget(_controller));
-
+ out.add(TimerWidget(_controller, ratioCompleted));
firstPage = false;
}
}
@@ -80,9 +108,16 @@ class _GymModeState extends State {
return PageView(
controller: _controller,
children: [
- StartPage(_controller, widget._workoutDay),
+ StartPage(
+ _controller,
+ widget._workoutDay,
+ ),
...out,
- SessionPage(workoutProvider.findById(widget._workoutDay.workoutId)),
+ SessionPage(
+ workoutProvider.findById(widget._workoutDay.workoutId),
+ _controller,
+ widget._start,
+ ),
],
);
}
@@ -98,59 +133,73 @@ class StartPage extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
AppLocalizations.of(context)!.todaysWorkout,
- style: Theme.of(context).textTheme.headline5,
+ style: Theme.of(context).textTheme.headline4,
),
),
- ..._day.sets.map(
- (set) {
- return Column(
- children: [
- ...set.settings.map((s) {
+ Divider(),
+ Expanded(
+ child: ListView(
+ children: [
+ ..._day.sets.map(
+ (set) {
return Column(
children: [
- Text(s.exerciseObj.name, style: TextStyle(fontWeight: FontWeight.bold)),
- Text(s.repsText),
- SizedBox(height: 10),
+ ...set.settingsFiltered.map((s) {
+ return Column(
+ children: [
+ Text(
+ s.exerciseObj.name,
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ Text(s.repsText),
+ SizedBox(height: 15),
+ ],
+ );
+ }).toList(),
],
);
- }).toList(),
- Divider(),
- ],
- );
- },
- ).toList(),
- Text('Here some text on what to do, etc. etc.'),
- Expanded(
- child: Container(),
+ },
+ ).toList(),
+ ],
+ ),
+ ),
+ ElevatedButton(
+ child: Text(AppLocalizations.of(context)!.start),
+ onPressed: () {
+ _controller.nextPage(duration: Duration(milliseconds: 200), curve: Curves.bounceIn);
+ },
+ ),
+ NavigationFooter(
+ _controller,
+ 0,
+ showPrevious: false,
),
- NavigationFooter(_controller),
],
),
);
}
}
-class LogPage extends StatelessWidget {
+class LogPage extends StatefulWidget {
PageController _controller;
Setting _setting;
Exercise _exercise;
WorkoutPlan _workoutPlan;
- Log _log = Log();
+ final double _ratioCompleted;
+ Log _log = Log.empty();
- final _form = GlobalKey();
final _repsController = TextEditingController();
final _weightController = TextEditingController();
final _rirController = TextEditingController();
- final _commentController = TextEditingController();
- LogPage(this._controller, this._setting, this._exercise, this._workoutPlan) {
+ LogPage(
+ this._controller, this._setting, this._exercise, this._workoutPlan, this._ratioCompleted) {
if (_setting.reps != null) {
_repsController.text = _setting.reps.toString();
}
@@ -164,65 +213,164 @@ class LogPage extends StatelessWidget {
}
_log.date = DateTime.now();
- _log.exercise = _exercise.id;
_log.workoutPlan = _workoutPlan.id!;
- _log.repetitionUnit = 1;
- _log.weightUnit = 1;
+ _log.exercise = _exercise;
+ _log.weightUnit = _setting.weightUnitObj;
+ _log.repetitionUnit = _setting.repetitionUnitObj;
}
+ @override
+ _LogPageState createState() => _LogPageState();
+}
+
+class _LogPageState extends State {
+ final _form = GlobalKey();
+ String rirValue = Setting.DEFAULT_RIR;
+
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
- _exercise.name,
+ widget._exercise.name,
style: Theme.of(context).textTheme.headline5,
+ textAlign: TextAlign.center,
),
),
- Expanded(child: Container()),
+ Divider(),
+ Center(
+ child: Text(
+ '${widget._setting.singleSettingRepText}',
+ style: Theme.of(context).textTheme.headline3,
+ textAlign: TextAlign.center,
+ ),
+ ),
+ Expanded(
+ child: (widget._workoutPlan.filterLogsByExercise(widget._exercise).length > 0)
+ ? ListView(
+ children: [
+ Text(
+ 'Logs',
+ style: Theme.of(context).textTheme.headline6,
+ textAlign: TextAlign.center,
+ ),
+ ...widget._workoutPlan.filterLogsByExercise(widget._exercise).map((log) {
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 40),
+ child: Row(
+ mainAxisSize: MainAxisSize.max,
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(DateFormat.yMd(Localizations.localeOf(context).languageCode)
+ .format(log.date)),
+ Text(
+ log.singleLogRepText,
+ textAlign: TextAlign.center,
+ ),
+ ],
+ ),
+ );
+ }).toList(),
+ ],
+ )
+ : Container()),
+ SizedBox(height: 15),
Form(
key: _form,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- TextFormField(
- decoration: InputDecoration(labelText: AppLocalizations.of(context)!.repetitions),
- controller: _repsController,
- keyboardType: TextInputType.number,
- onFieldSubmitted: (_) {},
- onSaved: (newValue) {
- _log.reps = int.parse(newValue!);
- },
- validator: (value) {
- try {
- double.parse(value!);
- } catch (error) {
- return AppLocalizations.of(context)!.enterValidNumber;
- }
- return null;
- },
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Flexible(
+ child: TextFormField(
+ decoration: InputDecoration(
+ labelText: AppLocalizations.of(context)!.repetitions,
+ prefixIcon: IconButton(
+ icon: Icon(
+ Icons.add,
+ color: Colors.black,
+ ),
+ onPressed: () {
+ try {
+ int newValue = int.parse(widget._repsController.text) + 1;
+ widget._repsController.text = newValue.toString();
+ } on FormatException catch (e) {}
+ },
+ ),
+ suffixIcon: IconButton(
+ icon: Icon(
+ Icons.remove,
+ color: Colors.black,
+ ),
+ onPressed: () {
+ try {
+ int newValue = int.parse(widget._repsController.text) - 1;
+ if (newValue > 0) {
+ widget._repsController.text = newValue.toString();
+ }
+ } on FormatException catch (e) {}
+ },
+ ),
+ ),
+ enabled: true,
+ controller: widget._repsController,
+ keyboardType: TextInputType.number,
+ onFieldSubmitted: (_) {},
+ onSaved: (newValue) {
+ widget._log.reps = int.parse(newValue!);
+ },
+ validator: (value) {
+ try {
+ int.parse(value!);
+ } catch (error) {
+ return AppLocalizations.of(context)!.enterValidNumber;
+ }
+ return null;
+ },
+ ),
+ ),
+ SizedBox(width: 8),
+ Flexible(
+ child: RepetitionUnitInputWidget(widget._log),
+ ),
+ ],
),
- TextFormField(
- decoration: InputDecoration(labelText: AppLocalizations.of(context)!.weight),
- controller: _weightController,
- keyboardType: TextInputType.number,
- onFieldSubmitted: (_) {},
- onSaved: (newValue) {
- _log.weight = double.parse(newValue!);
- },
- ),
- TextFormField(
- decoration: InputDecoration(labelText: AppLocalizations.of(context)!.rir),
- controller: _rirController,
- keyboardType: TextInputType.number,
- onFieldSubmitted: (_) {},
- onSaved: (newValue) {},
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Flexible(
+ child: TextFormField(
+ decoration:
+ InputDecoration(labelText: AppLocalizations.of(context)!.weight),
+ controller: widget._weightController,
+ keyboardType: TextInputType.number,
+ onFieldSubmitted: (_) {},
+ onSaved: (newValue) {
+ widget._log.weight = double.parse(newValue!);
+ },
+ validator: (value) {
+ try {
+ double.parse(value!);
+ } catch (error) {
+ return AppLocalizations.of(context)!.enterValidNumber;
+ }
+ return null;
+ },
+ ),
+ ),
+ SizedBox(width: 8),
+ Flexible(
+ child: WeightUnitInputWidget(widget._log),
+ )
+ ],
),
+ RiRInputWidget(widget._log),
/*
TextFormField(
decoration: InputDecoration(labelText: AppLocalizations.of(context)!.comment),
@@ -248,10 +396,17 @@ class LogPage extends StatelessWidget {
// Save the entry on the server
try {
- await Provider.of(context, listen: false).addLog(_log);
- //final snackBar = SnackBar(content: Text('Yay! A SnackBar!'));
- //ScaffoldMessenger.of(context).showSnackBar(snackBar);
- _controller.nextPage(
+ await Provider.of(context, listen: false).addLog(widget._log);
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(
+ duration: Duration(seconds: 2), // default is 4
+ content: Text(
+ AppLocalizations.of(context)!.successfullySaved,
+ textAlign: TextAlign.center,
+ ),
+ ),
+ );
+ widget._controller.nextPage(
duration: Duration(milliseconds: 200),
curve: Curves.bounceIn,
);
@@ -265,7 +420,7 @@ class LogPage extends StatelessWidget {
],
),
),
- NavigationFooter(_controller),
+ NavigationFooter(widget._controller, widget._ratioCompleted),
],
),
);
@@ -273,16 +428,16 @@ class LogPage extends StatelessWidget {
}
class ExerciseOverview extends StatelessWidget {
- PageController _controller;
- Exercise _exercise;
+ final PageController _controller;
+ final Exercise _exercise;
+ final double _ratioCompleted;
- ExerciseOverview(this._controller, this._exercise);
+ ExerciseOverview(this._controller, this._exercise, this._ratioCompleted);
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Column(
children: [
Padding(
@@ -290,12 +445,41 @@ class ExerciseOverview extends StatelessWidget {
child: Text(
_exercise.name,
style: Theme.of(context).textTheme.headline5,
+ textAlign: TextAlign.center,
),
),
+ Divider(),
Expanded(
- child: Text(_exercise.description),
+ child: ListView(
+ children: [
+ Text(
+ _exercise.categoryObj.name,
+ style: Theme.of(context).textTheme.headline6,
+ textAlign: TextAlign.center,
+ ),
+ ..._exercise.equipment
+ .map((e) => Text(
+ e.name,
+ style: Theme.of(context).textTheme.headline6,
+ textAlign: TextAlign.center,
+ ))
+ .toList(),
+ if (_exercise.images.length > 0)
+ Container(
+ width: double.infinity,
+ height: 200,
+ child: ListView(
+ scrollDirection: Axis.horizontal,
+ children: [
+ ..._exercise.images.map((e) => ExerciseImageWidget(image: e)).toList(),
+ ],
+ ),
+ ),
+ Html(data: _exercise.description),
+ ],
+ ),
),
- NavigationFooter(_controller),
+ NavigationFooter(_controller, _ratioCompleted),
],
),
);
@@ -304,8 +488,10 @@ class ExerciseOverview extends StatelessWidget {
class SessionPage extends StatefulWidget {
WorkoutPlan _workoutPlan;
+ PageController _controller;
+ TimeOfDay _start;
- SessionPage(this._workoutPlan);
+ SessionPage(this._workoutPlan, this._controller, this._start);
@override
_SessionPageState createState() => _SessionPageState();
@@ -321,53 +507,54 @@ class _SessionPageState extends State {
int impressionValue = 2;
var _session = WorkoutSession();
+ @override
+ void initState() {
+ super.initState();
+
+ timeStartController.text = timeToString(widget._start)!;
+ timeEndController.text = timeToString(TimeOfDay.now())!;
+ _session.workoutId = widget._workoutPlan.id!;
+ _session.date = DateTime.now();
+ }
+
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
- 'Session',
+ AppLocalizations.of(context)!.workoutSession,
style: Theme.of(context).textTheme.headline5,
),
),
+ Divider(),
Expanded(child: Container()),
Form(
key: _form,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- FormField(
- builder: (FormFieldState state) {
- return InputDecorator(
- decoration: InputDecoration(
- labelText: AppLocalizations.of(context)!.impression,
- ),
- child: DropdownButtonHideUnderline(
- child: DropdownButton(
- value: impressionValue,
- isDense: true,
- onChanged: (int? newValue) {
- setState(() {
- impressionValue = newValue!;
- state.didChange(newValue);
- });
- },
- items: ImpressionMap.keys.map>((int key) {
- return DropdownMenuItem(
- value: key,
- child: Text(
- ImpressionMap[key]!,
- ),
- );
- }).toList(),
- ),
- ),
+ DropdownButtonFormField(
+ value: impressionValue,
+ decoration: InputDecoration(
+ labelText: AppLocalizations.of(context)!.impression,
+ ),
+ items: ImpressionMap.keys.map>((int key) {
+ return DropdownMenuItem(
+ value: key,
+ child: Text(ImpressionMap[key]!),
);
+ }).toList(),
+ onSaved: (int? newValue) {
+ _session.impression = newValue!;
+ },
+ onChanged: (int? newValue) {
+ setState(() {
+ impressionValue = newValue!;
+ });
},
),
TextFormField(
@@ -390,7 +577,21 @@ class _SessionPageState extends State {
InputDecoration(labelText: AppLocalizations.of(context)!.timeStart),
controller: timeStartController,
onFieldSubmitted: (_) {},
- onSaved: (newValue) {},
+ onTap: () async {
+ // Stop keyboard from appearing
+ FocusScope.of(context).requestFocus(new FocusNode());
+
+ // Open time picker
+ var pickedTime = await showTimePicker(
+ context: context,
+ initialTime: widget._start,
+ );
+
+ timeStartController.text = timeToString(pickedTime)!;
+ },
+ onSaved: (newValue) {
+ _session.timeStart = stringToTime(newValue);
+ },
),
),
Flexible(
@@ -399,7 +600,21 @@ class _SessionPageState extends State {
InputDecoration(labelText: AppLocalizations.of(context)!.timeEnd),
controller: timeEndController,
onFieldSubmitted: (_) {},
- onSaved: (newValue) {},
+ onTap: () async {
+ // Stop keyboard from appearing
+ FocusScope.of(context).requestFocus(new FocusNode());
+
+ // Open time picker
+ var pickedTime = await showTimePicker(
+ context: context,
+ initialTime: TimeOfDay.now(),
+ );
+
+ timeStartController.text = timeToString(pickedTime)!;
+ },
+ onSaved: (newValue) {
+ _session.timeEnd = stringToTime(newValue);
+ },
),
),
],
@@ -413,9 +628,6 @@ class _SessionPageState extends State {
return;
}
_form.currentState!.save();
- _session.date = DateTime.now();
- _session.workoutId = widget._workoutPlan.id!;
- _session.impression = impressionValue;
// Save the entry on the server
try {
@@ -431,11 +643,10 @@ class _SessionPageState extends State {
],
),
),
- IconButton(
- icon: Icon(Icons.exit_to_app),
- onPressed: () {
- Navigator.of(context).pop();
- },
+ NavigationFooter(
+ widget._controller,
+ 1,
+ showNext: false,
),
],
),
@@ -444,9 +655,10 @@ class _SessionPageState extends State {
}
class TimerWidget extends StatefulWidget {
- PageController _controller;
+ final PageController _controller;
+ final double _ratioCompleted;
- TimerWidget(this._controller);
+ TimerWidget(this._controller, this._ratioCompleted);
@override
_TimerWidgetState createState() => _TimerWidgetState();
@@ -501,35 +713,17 @@ class _TimerWidgetState extends State {
Widget build(BuildContext context) {
return Container(
width: double.infinity,
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Column(
children: [
- Padding(
- padding: const EdgeInsets.symmetric(vertical: 10),
- child: Text(
- 'Timer',
- style: Theme.of(context).textTheme.headline5,
- ),
- ),
- /*
- ElevatedButton(
- child: Text("start"),
- onPressed: () {
- startTimer();
- },
- ),
-
- */
Expanded(
child: Center(
child: Text(
- //'${_seconds} sec',
DateFormat('m:ss').format(today.add(Duration(seconds: _seconds))),
- style: Theme.of(context).textTheme.headline1,
+ style: Theme.of(context).textTheme.headline1!.copyWith(color: wgerPrimaryColor),
),
),
),
- NavigationFooter(widget._controller),
+ NavigationFooter(widget._controller, widget._ratioCompleted),
],
),
);
@@ -538,31 +732,62 @@ class _TimerWidgetState extends State {
class NavigationFooter extends StatelessWidget {
final PageController _controller;
+ final double _ratioCompleted;
+ final bool showPrevious;
+ final bool showNext;
- NavigationFooter(this._controller);
+ NavigationFooter(this._controller, this._ratioCompleted,
+ {this.showPrevious = true, this.showNext = true});
@override
Widget build(BuildContext context) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
+ return Column(
children: [
- IconButton(
- icon: Icon(Icons.chevron_left),
- onPressed: () {
- _controller.previousPage(duration: Duration(milliseconds: 200), curve: Curves.bounceIn);
- },
+ SizedBox(height: 30),
+ LinearProgressIndicator(
+ minHeight: 1.5,
+ value: _ratioCompleted,
+ valueColor: AlwaysStoppedAnimation(wgerPrimaryColor),
+ backgroundColor: Colors.white,
),
- IconButton(
- icon: Icon(Icons.exit_to_app),
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- IconButton(
- icon: Icon(Icons.chevron_right),
- onPressed: () {
- _controller.nextPage(duration: Duration(milliseconds: 200), curve: Curves.bounceIn);
- },
+ Row(
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ // Nest all widgets in an expanded so that they all take the same size
+ // independently of how wide they are so that the buttons are positioned
+ // always on the same spot
+
+ Expanded(
+ child: showPrevious
+ ? IconButton(
+ icon: Icon(Icons.chevron_left),
+ onPressed: () {
+ _controller.previousPage(
+ duration: Duration(milliseconds: 200), curve: Curves.bounceIn);
+ },
+ )
+ : Container(),
+ ),
+ Expanded(
+ child: IconButton(
+ icon: Icon(Icons.exit_to_app),
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ Expanded(
+ child: showNext
+ ? IconButton(
+ icon: Icon(Icons.chevron_right),
+ onPressed: () {
+ _controller.nextPage(
+ duration: Duration(milliseconds: 200), curve: Curves.bounceIn);
+ },
+ )
+ : Container(),
+ ),
+ ],
),
],
);
diff --git a/lib/widgets/workouts/log.dart b/lib/widgets/workouts/log.dart
index b5dcacad7..9a21c9173 100644
--- a/lib/widgets/workouts/log.dart
+++ b/lib/widgets/workouts/log.dart
@@ -1,18 +1,18 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
@@ -137,11 +137,14 @@ class DayLogWidget extends StatelessWidget {
style: Theme.of(context).textTheme.headline5,
),
..._day.sets.map((set) => getSetRow(set)).toList(),
+ /*
OutlinedButton(
child: Text('Add logs to this day'),
onPressed: () {},
),
Padding(padding: const EdgeInsets.symmetric(vertical: 10.0))
+
+ */
],
),
);
diff --git a/lib/widgets/workouts/workout_logs.dart b/lib/widgets/workouts/workout_logs.dart
index bef110723..1b47e468d 100644
--- a/lib/widgets/workouts/workout_logs.dart
+++ b/lib/widgets/workouts/workout_logs.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -44,7 +44,7 @@ class _WorkoutLogsState extends State {
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
- 'Weight Log',
+ AppLocalizations.of(context)!.labelWorkoutLogs,
style: Theme.of(context).textTheme.headline5,
),
),
@@ -73,7 +73,7 @@ class _WorkoutLogsState extends State {
),
),
ElevatedButton(
- child: Text('Back to workout'),
+ child: Text(AppLocalizations.of(context)!.labelWorkoutPlan),
onPressed: () {
widget._changeMode(WorkoutScreenMode.workout);
},
diff --git a/lib/widgets/workouts/workout_plan_detail.dart b/lib/widgets/workouts/workout_plan_detail.dart
index 205eb4180..019fa98b6 100644
--- a/lib/widgets/workouts/workout_plan_detail.dart
+++ b/lib/widgets/workouts/workout_plan_detail.dart
@@ -1,26 +1,25 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:wger/models/workouts/workout_plan.dart';
import 'package:wger/screens/form_screen.dart';
-import 'package:wger/screens/workout_plan_screen.dart';
import 'package:wger/widgets/workouts/day.dart';
import 'package:wger/widgets/workouts/forms.dart';
@@ -57,7 +56,7 @@ class _WorkoutPlanDetailState extends State {
Column(
children: [
ElevatedButton(
- child: Text(AppLocalizations.of(context)!.add),
+ child: Text(AppLocalizations.of(context)!.newDay),
onPressed: () {
Navigator.pushNamed(
context,
@@ -65,16 +64,19 @@ class _WorkoutPlanDetailState extends State {
arguments: FormScreenArguments(
AppLocalizations.of(context)!.newDay,
DayFormWidget(widget._workoutPlan),
+ true,
),
);
},
),
+ /*
ElevatedButton(
child: Text('View logs'),
onPressed: () {
widget._changeMode(WorkoutScreenMode.log);
},
),
+ */
],
),
],
diff --git a/lib/widgets/workouts/workout_plans_list.dart b/lib/widgets/workouts/workout_plans_list.dart
index 2a2ed6c99..75fcbfc73 100644
--- a/lib/widgets/workouts/workout_plans_list.dart
+++ b/lib/widgets/workouts/workout_plans_list.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
@@ -65,7 +65,7 @@ class WorkoutPlansList extends StatelessWidget {
Navigator.of(contextDialog).pop();
// and inform the user
- Scaffold.of(context).showSnackBar(
+ ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.of(context)!.successfullyDeleted,
diff --git a/pubspec.lock b/pubspec.lock
index cbce0116a..4772ff1a0 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -7,14 +7,14 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
- version: "19.0.0"
+ version: "20.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0"
+ version: "1.4.0"
android_metadata:
dependency: "direct main"
description:
@@ -141,6 +141,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
+ chewie:
+ dependency: transitive
+ description:
+ name: chewie
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.12.2"
+ chewie_audio:
+ dependency: transitive
+ description:
+ name: chewie_audio
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.2"
cli_util:
dependency: transitive
description:
@@ -182,7 +196,21 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
- version: "3.0.0"
+ version: "3.0.1"
+ css_colors:
+ dependency: transitive
+ description:
+ name: css_colors
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
+ csslib:
+ dependency: transitive
+ description:
+ name: csslib
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.16.2"
cupertino_icons:
dependency: "direct main"
description:
@@ -236,7 +264,14 @@ packages:
name: flutter_calendar_carousel
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.0.1"
+ flutter_html:
+ dependency: "direct main"
+ description:
+ name: flutter_html
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.3.0"
flutter_keyboard_visibility:
dependency: transitive
description:
@@ -265,11 +300,25 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0"
+ flutter_layout_grid:
+ dependency: transitive
+ description:
+ name: flutter_layout_grid
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.10.5"
flutter_localizations:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
+ flutter_svg:
+ dependency: transitive
+ description:
+ name: flutter_svg
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.20.0-nullsafety.3"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -301,6 +350,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
+ html:
+ dependency: transitive
+ description:
+ name: html
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.14.0+4"
http:
dependency: "direct main"
description:
@@ -314,7 +370,7 @@ packages:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
- version: "3.0.0"
+ version: "3.0.1"
http_parser:
dependency: transitive
description:
@@ -329,6 +385,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
+ import_js_library:
+ dependency: transitive
+ description:
+ name: import_js_library
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.2"
intl:
dependency: "direct main"
description:
@@ -398,7 +461,7 @@ packages:
name: mockito
url: "https://pub.dartlang.org"
source: hosted
- version: "5.0.3"
+ version: "5.0.4"
nested:
dependency: transitive
description:
@@ -427,6 +490,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
+ path_drawing:
+ dependency: transitive
+ description:
+ name: path_drawing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.5.0"
+ path_parsing:
+ dependency: transitive
+ description:
+ name: path_parsing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.0"
path_provider_linux:
dependency: transitive
description:
@@ -461,7 +538,7 @@ packages:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
- version: "4.0.2"
+ version: "4.1.0"
platform:
dependency: transitive
description:
@@ -511,6 +588,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
+ quiver:
+ dependency: transitive
+ description:
+ name: quiver
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.5"
shared_preferences:
dependency: "direct main"
description:
@@ -705,6 +789,48 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
+ video_player:
+ dependency: transitive
+ description:
+ name: video_player
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.1"
+ video_player_platform_interface:
+ dependency: transitive
+ description:
+ name: video_player_platform_interface
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.2.0"
+ video_player_web:
+ dependency: transitive
+ description:
+ name: video_player_web
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4+1"
+ wakelock:
+ dependency: transitive
+ description:
+ name: wakelock
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.1+1"
+ wakelock_platform_interface:
+ dependency: transitive
+ description:
+ name: wakelock_platform_interface
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.0+1"
+ wakelock_web:
+ dependency: transitive
+ description:
+ name: wakelock_web
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.0+3"
watcher:
dependency: transitive
description:
@@ -719,6 +845,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
+ webview_flutter:
+ dependency: transitive
+ description:
+ name: webview_flutter
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.7"
win32:
dependency: transitive
description:
@@ -739,7 +872,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
- version: "5.0.2"
+ version: "5.1.0"
yaml:
dependency: transitive
description:
@@ -749,4 +882,4 @@ packages:
version: "3.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
- flutter: ">=1.22.0"
+ flutter: ">=1.24.0-7.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 13ff2f929..8de5e2f58 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 0.1.0+7
+version: 0.2.0+9
environment:
sdk: '>=2.12.0 <3.0.0'
@@ -30,7 +30,7 @@ dependencies:
intl: ^0.17.0
http: ^0.13.0
shared_preferences: ^2.0.5
- flutter_calendar_carousel: ^2.0.0
+ flutter_calendar_carousel: ^2.0.1
cupertino_icons: ^1.0.0
json_annotation: ^4.0.0
url_launcher: ^6.0.2
@@ -40,6 +40,7 @@ dependencies:
package_info: ^2.0.0
android_metadata: ^0.1.3
collection: ^1.15.0-nullsafety.4
+ flutter_html: ^1.3.0
dev_dependencies:
flutter_test:
diff --git a/test/auth_screen_test.dart b/test/auth_screen_test.dart
index cd09dd797..938233757 100644
--- a/test/auth_screen_test.dart
+++ b/test/auth_screen_test.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter/material.dart';
diff --git a/test/base_provider_test.dart b/test/base_provider_test.dart
index 9392cda94..bfec04ae9 100644
--- a/test/base_provider_test.dart
+++ b/test/base_provider_test.dart
@@ -1,19 +1,19 @@
/*
* This file is part of wger Workout Manager .
- * Copyright (C) 2020 wger Team
+ * Copyright (C) 2020, 2021 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * 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.
*
* wger Workout Manager 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 General Public License for more details.
+ * GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
*/
import 'package:flutter_test/flutter_test.dart';
diff --git a/test/base_provider_test.mocks.dart b/test/base_provider_test.mocks.dart
index bb43da439..25938e29e 100644
--- a/test/base_provider_test.mocks.dart
+++ b/test/base_provider_test.mocks.dart
@@ -1,4 +1,4 @@
-// Mocks generated by Mockito 5.0.3 from annotations
+// Mocks generated by Mockito 5.0.4 from annotations
// in wger/test/base_provider_test.dart.
// Do not manually edit this file.
@@ -32,12 +32,12 @@ class MockClient extends _i1.Mock implements _i5.Client {
@override
_i6.Future<_i2.Response> head(Uri? url, {Map? headers}) =>
(super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}),
- returnValue: Future.value(_FakeResponse()))
+ returnValue: Future<_i2.Response>.value(_FakeResponse()))
as _i6.Future<_i2.Response>);
@override
_i6.Future<_i2.Response> get(Uri? url, {Map? headers}) =>
(super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}),
- returnValue: Future.value(_FakeResponse()))
+ returnValue: Future<_i2.Response>.value(_FakeResponse()))
as _i6.Future<_i2.Response>);
@override
_i6.Future<_i2.Response> post(Uri? url,
@@ -47,7 +47,7 @@ class MockClient extends _i1.Mock implements _i5.Client {
(super.noSuchMethod(
Invocation.method(#post, [url],
{#headers: headers, #body: body, #encoding: encoding}),
- returnValue: Future.value(_FakeResponse()))
+ returnValue: Future<_i2.Response>.value(_FakeResponse()))
as _i6.Future<_i2.Response>);
@override
_i6.Future<_i2.Response> put(Uri? url,
@@ -57,7 +57,7 @@ class MockClient extends _i1.Mock implements _i5.Client {
(super.noSuchMethod(
Invocation.method(#put, [url],
{#headers: headers, #body: body, #encoding: encoding}),
- returnValue: Future.value(_FakeResponse()))
+ returnValue: Future<_i2.Response>.value(_FakeResponse()))
as _i6.Future<_i2.Response>);
@override
_i6.Future<_i2.Response> patch(Uri? url,
@@ -67,7 +67,7 @@ class MockClient extends _i1.Mock implements _i5.Client {
(super.noSuchMethod(
Invocation.method(#patch, [url],
{#headers: headers, #body: body, #encoding: encoding}),
- returnValue: Future.value(_FakeResponse()))
+ returnValue: Future<_i2.Response>.value(_FakeResponse()))
as _i6.Future<_i2.Response>);
@override
_i6.Future<_i2.Response> delete(Uri? url,
@@ -77,22 +77,26 @@ class MockClient extends _i1.Mock implements _i5.Client {
(super.noSuchMethod(
Invocation.method(#delete, [url],
{#headers: headers, #body: body, #encoding: encoding}),
- returnValue: Future.value(_FakeResponse()))
+ returnValue: Future<_i2.Response>.value(_FakeResponse()))
as _i6.Future<_i2.Response>);
@override
_i6.Future read(Uri? url, {Map? headers}) =>
(super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}),
- returnValue: Future.value('')) as _i6.Future);
+ returnValue: Future.value('')) as _i6.Future);
@override
_i6.Future<_i3.Uint8List> readBytes(Uri? url,
{Map? headers}) =>
(super.noSuchMethod(
Invocation.method(#readBytes, [url], {#headers: headers}),
- returnValue: Future.value(_FakeUint8List()))
+ returnValue: Future<_i3.Uint8List>.value(_FakeUint8List()))
as _i6.Future<_i3.Uint8List>);
@override
_i6.Future<_i4.StreamedResponse> send(_i8.BaseRequest? request) =>
(super.noSuchMethod(Invocation.method(#send, [request]),
- returnValue: Future.value(_FakeStreamedResponse()))
+ returnValue:
+ Future<_i4.StreamedResponse>.value(_FakeStreamedResponse()))
as _i6.Future<_i4.StreamedResponse>);
+ @override
+ void close() => super.noSuchMethod(Invocation.method(#close, []),
+ returnValueForMissingStub: null);
}
diff --git a/test/gym_mode_screen_test.dart b/test/gym_mode_screen_test.dart
new file mode 100644
index 000000000..e93591593
--- /dev/null
+++ b/test/gym_mode_screen_test.dart
@@ -0,0 +1,140 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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.
+ *
+ * wger Workout Manager 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 .
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:provider/provider.dart';
+import 'package:wger/models/workouts/workout_plan.dart';
+import 'package:wger/providers/workout_plans.dart';
+import 'package:wger/screens/gym_mode.dart';
+import 'package:wger/screens/workout_plan_screen.dart';
+import 'package:wger/widgets/workouts/gym_mode.dart';
+
+import '../test_data/workouts.dart';
+import 'base_provider_test.mocks.dart';
+import 'utils.dart';
+
+void main() {
+ Widget createHomeScreen({locale = 'en'}) {
+ final key = GlobalKey();
+ final client = MockClient();
+
+ WorkoutPlan workoutPlan = getWorkout();
+
+ return ChangeNotifierProvider(
+ create: (context) => WorkoutPlans(
+ testAuthProvider,
+ testExercisesProvider,
+ [workoutPlan],
+ client,
+ ),
+ child: ChangeNotifierProvider(
+ create: (context) => testExercisesProvider,
+ child: MaterialApp(
+ locale: Locale(locale),
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
+ supportedLocales: AppLocalizations.supportedLocales,
+ navigatorKey: key,
+ home: TextButton(
+ onPressed: () => key.currentState!.push(
+ MaterialPageRoute(
+ settings: RouteSettings(arguments: workoutPlan.days.first),
+ builder: (_) => GymModeScreen(),
+ ),
+ ),
+ child: const SizedBox(),
+ ),
+ routes: {
+ WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
+ },
+ ),
+ ),
+ );
+ }
+
+ testWidgets('Test the widgets on the gym mode screen', (WidgetTester tester) async {
+ await tester.pumpWidget(createHomeScreen());
+ await tester.tap(find.byType(TextButton));
+ await tester.pumpAndSettle();
+
+ // Start page
+ expect(find.byType(StartPage), findsOneWidget);
+ expect(find.text('Your workout today'), findsOneWidget);
+ expect(find.text('test exercise 1'), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_left), findsNothing);
+ expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_right), findsOneWidget);
+ await tester.tap(find.byIcon(Icons.chevron_right));
+ await tester.pumpAndSettle();
+
+ // Exercise overview page
+ expect(find.text('test exercise 1'), findsOneWidget);
+ expect(find.byType(ExerciseOverview), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_left), findsOneWidget);
+ expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_right), findsOneWidget);
+ await tester.drag(find.byType(ExerciseOverview), Offset(-500.0, 0.0));
+ await tester.pumpAndSettle();
+
+ // Log
+ expect(find.text('test exercise 1'), findsOneWidget);
+ expect(find.byType(LogPage), findsOneWidget);
+ expect(find.byType(Form), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_left), findsOneWidget);
+ expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_right), findsOneWidget);
+ await tester.drag(find.byType(LogPage), Offset(-500.0, 0.0));
+ await tester.pumpAndSettle();
+
+ // Pause
+ expect(find.text('0:00'), findsOneWidget);
+ expect(find.byType(TimerWidget), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_left), findsOneWidget);
+ expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_right), findsOneWidget);
+ await tester.tap(find.byIcon(Icons.chevron_right));
+ await tester.pumpAndSettle();
+
+ // Log
+ expect(find.text('test exercise 1'), findsOneWidget);
+ expect(find.byType(LogPage), findsOneWidget);
+ expect(find.byType(Form), findsOneWidget);
+ await tester.drag(find.byType(LogPage), Offset(-500.0, 0.0));
+ await tester.pumpAndSettle();
+
+ // Pause
+ expect(find.text('0:00'), findsOneWidget);
+ expect(find.byType(TimerWidget), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_left), findsOneWidget);
+ expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_right), findsOneWidget);
+ await tester.tap(find.byIcon(Icons.chevron_right));
+ await tester.pumpAndSettle();
+
+ // Session
+ expect(find.text('Workout session'), findsOneWidget);
+ expect(find.byType(SessionPage), findsOneWidget);
+ expect(find.byType(Form), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_left), findsOneWidget);
+ expect(find.byIcon(Icons.exit_to_app), findsOneWidget);
+ expect(find.byIcon(Icons.chevron_right), findsNothing);
+
+ //
+ });
+}
diff --git a/test/nutritional_plan_screen_test.dart b/test/nutritional_plan_screen_test.dart
new file mode 100644
index 000000000..247426d18
--- /dev/null
+++ b/test/nutritional_plan_screen_test.dart
@@ -0,0 +1,102 @@
+/*
+ * This file is part of wger Workout Manager .
+ * Copyright (C) 2020, 2021 wger Team
+ *
+ * wger Workout Manager 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.
+ *
+ * wger Workout Manager 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