Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 24 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,46 @@
<header>

<!--
<<< Author notes: Course header >>>
Read <https://skills.github.com/quickstart> for more information about how to build courses using this template.
Include a 1280×640 image, course name in sentence case, and a concise description in emphasis.
In your repository settings: enable template repository, add your 1280×640 social image, auto delete head branches.
Next to "About", add description & tags; disable releases, packages, & environments.
Add your open source license, GitHub uses the MIT license.
-->
# Bodybuilding Trainer and Nutrition App

# Code with GitHub Copilot

_GitHub Copilot can help you code by offering autocomplete-style suggestions right in VS Code and Codespaces._
_Enhance and expand a Bodybuilding Trainer and Nutrition App with advanced features and functionality tailored for a professional bodybuilder._

</header>

<!--
<<< Author notes: Step 1 >>>
Choose 3-5 steps for your course.
The first step is always the hardest, so pick something easy!
Link to docs.github.com for further explanations.
Encourage users to open new tabs for steps!
-->

## Step 1: Leverage Codespaces with VS Code for Copilot

_Welcome to "Develop With AI Powered Code Suggestions Using GitHub Copilot and VS Code"! :wave:_

GitHub Copilot is an AI pair programmer that helps you write code faster and with less work. It draws context from comments and code to suggest individual lines and whole functions instantly. GitHub Copilot is powered by OpenAI Codex, a generative pretrained language model created by OpenAI.
## App Overview

**Copilot works with many code editors including VS Code, Visual Studio, JetBrains IDE, and Neovim.**
The Bodybuilding Trainer and Nutrition App is designed to provide professional bodybuilders with a comprehensive tool for managing their training schedules, nutrition plans, hormone tracking, and progress tracking. The app includes core features such as training schedules, nutrition and diet plans, hormone tracking system, body stats tracking, recurring notifications, and progress photos. It also offers advanced features for trainers to manage multiple clients, personalized schedules, and detailed tracking of stats and progress.

Additionally, GitHub Copilot is trained on all languages that appear in public repositories. For each language, the quality of suggestions you receive may depend on the volume and diversity of training data for that language.
## Folder Structure

Using Copilot inside a Codespace shows just how easy it is to get up and running with GitHub's suite of [Collaborative Coding](https://github.com/features#features-collaboration) tools.
The app follows a modular folder structure to ensure clean and maintainable code. The main folders are:

> **Note**
> This skills exercise will focus on leveraging GitHub Codespace. It is recommended that you complete the GitHub skill, [Codespaces](https://github.com/skills/code-with-codespaces), before moving forward with this exercise.
- `lib/screens`: Contains screens like dashboards, profiles, and tracking.
- `lib/widgets`: Contains reusable UI components (e.g., cards, graphs).
- `lib/models`: Contains data models (e.g., hormones, user profiles).
- `lib/services`: Contains backend integrations and logic.
- `lib/database`: Contains SQLite database integration.

### :keyboard: Activity: Enable Copilot inside a Codespace
## Setup Instructions

**We recommend opening another browser tab to work through the following activities so you can keep these instructions open for reference.**

Before you open up a codespace on a repository, you can create a development container and define specific extensions or configurations that will be used or installed in your codespace. Let's create this development container and add copilot to the list of extensions.

1. Navigating back to your **Code** tab of your repository, click the **Add file** drop-down button, and then click `Create new file`.
1. Type or paste the following in the empty text field prompt to name your file.
1. Clone the repository:
```
.devcontainer/devcontainer.json
git clone https://github.com/sakura-source/Werdany.git
```
1. In the body of the new **.devcontainer/devcontainer.json** file, add the following content:
2. Navigate to the project directory:
```
{
// Name this configuration
"name": "Codespace for Skills!",
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot"
]
}
}
}
cd Werdany
```
3. Install dependencies:
```
flutter pub get
```
4. Run the app:
```
flutter run
```
1. Select the option to **Commit directly to the `main` branch**, and then click the **Commit new file** button.
1. Navigate back to the home page of your repository by clicking the **Code** tab located at the top left of the screen.
1. Click the **Code** button located in the middle of the page.
1. Click the **Codespaces** tab on the box that pops up.
1. Click the **Create codespace on main** button.

**Wait about 2 minutes for the codespace to spin itself up.**

1. Verify your codespace is running. The browser should contain a VS Code web-based editor and a terminal should be present such as the below:
![Screen Shot 2023-03-09 at 9 09 07 AM](https://user-images.githubusercontent.com/26442605/224102962-d0222578-3f10-4566-856d-8d59f28fcf2e.png)
1. The `copilot` extension should show up in the VS Code extension list. Click the extensions sidebar tab. You should see the following:
![Screen Shot 2023-03-09 at 9 04 13 AM](https://user-images.githubusercontent.com/26442605/224102514-7d6d2f51-f435-401d-a529-7bae3ae3e511.png)

**Wait about 60 seconds then refresh your repository landing page for the next step.**

<footer>

<!--
<<< Author notes: Footer >>>
Add a link to get support, GitHub status page, code of conduct, license link.
-->

---

Get help: [Post in our discussion board](https://github.com/orgs/skills/discussions/categories/code-with-copilot) &bull; [Review the GitHub status page](https://www.githubstatus.com/)
Expand Down
99 changes: 99 additions & 0 deletions lib/database/database_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';

class DatabaseHelper {
static final DatabaseHelper _instance = DatabaseHelper._internal();
factory DatabaseHelper() => _instance;
DatabaseHelper._internal();

Database? _database;

Future<Database> get database async {
if (_database != null) return _database!;
_database = await _initDatabase();
return _database!;
}

Future<Database> _initDatabase() async {
String path = join(await getDatabasesPath(), 'app_database.db');
return await openDatabase(
path,
version: 1,
onCreate: (db, version) async {
await db.execute('''
CREATE TABLE body_stats (
id INTEGER PRIMARY KEY AUTOINCREMENT,
weight REAL,
muscleMass REAL,
fatPercentage REAL
)
''');
await db.execute('''
CREATE TABLE hormones (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
dosage REAL,
schedule TEXT,
purpose TEXT
)
''');
await db.execute('''
CREATE TABLE diet_plans (
id INTEGER PRIMARY KEY AUTOINCREMENT,
calories INTEGER,
protein INTEGER,
carbs INTEGER,
fats INTEGER
)
''');
await db.execute('''
CREATE TABLE progress_photos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
photoPath TEXT,
date TEXT
)
''');
await db.execute('''
CREATE TABLE trainer_profiles (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
clients TEXT
)
''');
},
);
}

Future<void> insert(String table, Map<String, dynamic> data) async {
final db = await database;
await db.insert(
table,
data,
conflictAlgorithm: ConflictAlgorithm.replace,
);
}

Future<void> update(String table, Map<String, dynamic> data, String where, List<dynamic> whereArgs) async {
final db = await database;
await db.update(
table,
data,
where: where,
whereArgs: whereArgs,
);
}

Future<void> delete(String table, String where, List<dynamic> whereArgs) async {
final db = await database;
await db.delete(
table,
where: where,
whereArgs: whereArgs,
);
}

Future<List<Map<String, dynamic>>> query(String table) async {
final db = await database;
return await db.query(table);
}
}
23 changes: 23 additions & 0 deletions lib/models/body_stats.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class BodyStats {
double weight;
double muscleMass;
double fatPercentage;

BodyStats({required this.weight, required this.muscleMass, required this.fatPercentage});

factory BodyStats.fromJson(Map<String, dynamic> json) {
return BodyStats(
weight: json['weight'],
muscleMass: json['muscleMass'],
fatPercentage: json['fatPercentage'],
);
}

Map<String, dynamic> toJson() {
return {
'weight': weight,
'muscleMass': muscleMass,
'fatPercentage': fatPercentage,
};
}
}
35 changes: 35 additions & 0 deletions lib/models/diet_plan.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class DietPlan {
int id;
int calories;
int protein;
int carbs;
int fats;

DietPlan({
required this.id,
required this.calories,
required this.protein,
required this.carbs,
required this.fats,
});

factory DietPlan.fromJson(Map<String, dynamic> json) {
return DietPlan(
id: json['id'],
calories: json['calories'],
protein: json['protein'],
carbs: json['carbs'],
fats: json['fats'],
);
}

Map<String, dynamic> toJson() {
return {
'id': id,
'calories': calories,
'protein': protein,
'carbs': carbs,
'fats': fats,
};
}
}
35 changes: 35 additions & 0 deletions lib/models/hormone.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class Hormone {
int id;
String name;
double dosage;
String schedule;
String purpose;

Hormone({
required this.id,
required this.name,
required this.dosage,
required this.schedule,
required this.purpose,
});

factory Hormone.fromJson(Map<String, dynamic> json) {
return Hormone(
id: json['id'],
name: json['name'],
dosage: json['dosage'],
schedule: json['schedule'],
purpose: json['purpose'],
);
}

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'dosage': dosage,
'schedule': schedule,
'purpose': purpose,
};
}
}
Loading