rename to one trip
BIN
grocery_helper/assets/icons/desktop.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
101
grocery_helper/assets/images/desktop.svg
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="512"
|
||||
height="512"
|
||||
viewBox="0 0 512 512"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
sodipodi:docname="desktop.svg"
|
||||
inkscape:version="1.2.1 (8a69933317, 2022-10-28, custom)"
|
||||
inkscape:export-filename="../590e5273/desktop.png"
|
||||
inkscape:export-xdpi="192"
|
||||
inkscape:export-ydpi="192"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview7"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="px"
|
||||
showgrid="true"
|
||||
inkscape:zoom="1"
|
||||
inkscape:cx="144"
|
||||
inkscape:cy="284.99999"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1003"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1"
|
||||
showguides="false">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid312"
|
||||
spacingx="16"
|
||||
spacingy="16"
|
||||
empspacing="4" />
|
||||
</sodipodi:namedview>
|
||||
<defs
|
||||
id="defs2" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="matrix(1.2307692,0,0,1.2307692,-59.076907,-97.883539)">
|
||||
<rect
|
||||
style="display:inline;fill:#10599e;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:square;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:0.200103"
|
||||
id="rect1850"
|
||||
width="416"
|
||||
height="416"
|
||||
x="48"
|
||||
y="48"
|
||||
ry="208"
|
||||
inkscape:label="BG"
|
||||
transform="translate(-1.15e-5,31.530375)" />
|
||||
<path
|
||||
id="rect421"
|
||||
style="fill:#000000;fill-opacity:0.238453;stroke:#e5e5e5;stroke-width:0;stroke-linecap:square;stroke-linejoin:miter;stroke-dasharray:none"
|
||||
inkscape:label="Shadow"
|
||||
d="m 98.234375,198.10547 14.187505,166.73633 55.44921,79.69922 C 194.60919,457.00549 224.45145,464 256,464 370.14686,464 462.19359,372.956 463.91797,259.23438 L 432,198.10547 Z"
|
||||
transform="translate(-1.15e-5,31.530375)" />
|
||||
<rect
|
||||
style="display:inline;fill:#10599e;fill-opacity:0;stroke:#0b3763;stroke-width:9.765;stroke-linecap:square;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect2621"
|
||||
width="406.23474"
|
||||
height="406.23474"
|
||||
x="52.882618"
|
||||
y="84.413002"
|
||||
ry="203.11737"
|
||||
inkscape:label="BG Border" />
|
||||
<path
|
||||
id="path5148"
|
||||
style="fill:#e5e5e5;fill-opacity:1;stroke:#e5e5e5;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="Basket"
|
||||
d="M 89.263157,243.53037 112.42105,396.37248 H 279.1579 399.57894 l 23.15788,-152.8421 z m 13.894733,23.15789 h 13.89473 l 18.52632,115.78947 H 121.6842 Z m 32.42105,0 h 13.89474 l 13.89474,115.78947 h -13.89474 z m 32.42106,0 h 13.89474 l 1.11085,13.89473 h -13.89474 z m 32.42105,0 h 13.89473 l 0.55543,13.89473 h -13.89473 z m 32.42105,0 h 13.89473 v 13.89473 H 232.8421 Z m 32.42105,0 h 13.89475 v 13.89473 h -13.89475 z m 32.42106,0 h 13.89473 l -0.55542,13.89473 h -13.89474 z m 32.42104,0 h 13.89474 l -1.11085,13.89473 H 328.9944 Z m 32.42105,0 h 13.89475 L 362.5263,382.47773 h -13.89474 z m 32.42107,0 h 13.89473 l -18.52631,115.78947 h -13.89474 z m -225.09474,23.15789 h 13.89474 17.6 13.89474 l 2.77894,69.47369 h -13.89474 -14.82104 -13.89474 z m 62.98947,0 h 13.89473 l 18.52632,37.05262 v -37.05262 h 13.89475 v 69.47369 H 265.26315 L 246.73683,322.2672 v 37.05264 H 232.8421 Z m 63.91578,0 h 13.89474 28.71579 2.77895 l -1.11085,13.89473 h -13.89474 -0.27862 -16.76595 l -0.55543,13.89474 h 16.11646 l -1.11087,13.89474 h -15.56281 l -0.55543,13.89475 h 15.19194 0.18453 13.89473 l -1.11086,13.89473 h -1.85262 -26.86316 -13.89474 z m -111.89966,13.89473 3.33438,41.68423 h 15.37828 l -1.66808,-41.68423 z m -8.70592,64.84211 h 13.89474 l 1.11085,13.89474 h -13.89473 z m 28.3449,0 h 13.89474 l 0.55542,13.89474 h -13.89473 z m 28.3449,0 h 13.89473 v 13.89474 H 232.8421 Z m 32.42105,0 h 13.89475 v 13.89474 h -13.89475 z m 28.34491,0 h 13.89473 l -0.55543,13.89474 h -13.89473 z m 28.34489,0 h 13.89473 l -1.11085,13.89474 H 320.8421 Z" />
|
||||
<path
|
||||
style="fill:#111111;fill-opacity:1;stroke:#e5e5e5;stroke-width:18.5263;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 163.36843,238.89881 46.31578,-111.1579"
|
||||
id="path10618"
|
||||
inkscape:label="LHandle" />
|
||||
<path
|
||||
style="fill:#111111;fill-opacity:1;stroke:#e5e5e5;stroke-width:18.5263;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 348.63158,238.89881 302.3158,127.74091"
|
||||
id="path10620"
|
||||
inkscape:label="RHandle" />
|
||||
<path
|
||||
style="fill:#898989;fill-opacity:1;stroke:#233459;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 80,252.79353 v -23.1579 h 352 v 23.1579 z"
|
||||
id="path8930"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
inkscape:label="Rim" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.3 KiB |
@@ -35,7 +35,7 @@ class Homegroup {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<Homegroup?> fetchHomegroup(int id) async {
|
||||
static Future<Homegroup?> get(int id) async {
|
||||
String requestURL = "$baseURL/api/homegroups/$id/";
|
||||
|
||||
String token = TokenSingleton().getToken();
|
||||
@@ -52,7 +52,7 @@ class Homegroup {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Homegroup?> createHomegroup(String title) async {
|
||||
static Future<Homegroup?> create(String title) async {
|
||||
String requestURL = "$baseURL/api/homegroups/";
|
||||
|
||||
String token = TokenSingleton().getToken();
|
||||
|
||||
@@ -37,8 +37,7 @@ class HomegroupInvite {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<HomegroupInvite?> createInvite(
|
||||
int homegroupID, int userID) async {
|
||||
static Future<HomegroupInvite?> create(int homegroupID, int userID) async {
|
||||
String requestURL = "$baseURL/api/groupinvites/";
|
||||
String token = TokenSingleton().getToken();
|
||||
final http.Response response = await http.post(
|
||||
@@ -54,7 +53,7 @@ class HomegroupInvite {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<bool> deleteInvite() async {
|
||||
Future<bool> delete() async {
|
||||
String requestURL = "$baseURL/api/groupinvites/$id/";
|
||||
String token = TokenSingleton().getToken();
|
||||
final http.Response response = await http.delete(
|
||||
|
||||
@@ -8,10 +8,15 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
class Recipe {
|
||||
int id;
|
||||
int homegroup;
|
||||
String name;
|
||||
List<Ingredient> ingredients;
|
||||
|
||||
Recipe({required this.id, required this.name, required this.ingredients});
|
||||
Recipe(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.ingredients,
|
||||
required this.homegroup});
|
||||
|
||||
factory Recipe.fromJson(Map<String, dynamic> json) {
|
||||
List<Ingredient> ingredients = [];
|
||||
@@ -20,11 +25,12 @@ class Recipe {
|
||||
}
|
||||
return Recipe(
|
||||
id: json["id"] as int,
|
||||
homegroup: json["homegroup"] as int,
|
||||
name: json["name"] as String,
|
||||
ingredients: ingredients);
|
||||
}
|
||||
|
||||
static Future<Recipe?> fetch(int id) async {
|
||||
static Future<Recipe?> get(int id) async {
|
||||
String requestURL = "$baseURL/api/recipes/$id/";
|
||||
|
||||
String token = TokenSingleton().getToken();
|
||||
@@ -40,15 +46,15 @@ class Recipe {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<List<Recipe>> fetchList(int groupID) async {
|
||||
Homegroup? group = await Homegroup.fetchHomegroup(groupID);
|
||||
static Future<List<Recipe>> getList(int groupID) async {
|
||||
Homegroup? group = await Homegroup.get(groupID);
|
||||
if (group == null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
List<Recipe> recipes = [];
|
||||
for (int recipeID in group.recipes) {
|
||||
Recipe? recipe = await Recipe.fetch(recipeID);
|
||||
Recipe? recipe = await Recipe.get(recipeID);
|
||||
if (recipe != null) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
@@ -56,4 +62,20 @@ class Recipe {
|
||||
|
||||
return recipes;
|
||||
}
|
||||
|
||||
static Future<Recipe?> create(String name, int group) async {
|
||||
String requestURL = "$baseURL/api/recipes/";
|
||||
String token = TokenSingleton().getToken();
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(requestURL),
|
||||
headers: {"Authorization": "Token $token"},
|
||||
body: {"homegroup": "$group", "name": name},
|
||||
);
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
return Recipe.fromJson(jsonDecode(response.body));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class SimpleUser {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<SimpleUser?> fetchUser({int? id}) async {
|
||||
static Future<SimpleUser?> get({int? id}) async {
|
||||
String requestURL = "$baseURL/auth/users/${id ?? 'me'}";
|
||||
|
||||
String token = TokenSingleton().getToken();
|
||||
|
||||
@@ -39,7 +39,7 @@ class User {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<User?> fetchUser() async {
|
||||
static Future<User?> getMe() async {
|
||||
String requestURL = "$baseURL/auth/users/me";
|
||||
|
||||
String token = TokenSingleton().getToken();
|
||||
@@ -56,7 +56,7 @@ class User {
|
||||
}
|
||||
}
|
||||
|
||||
Future<User?> patch({
|
||||
Future<User?> patchMe({
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
int? homegroup,
|
||||
|
||||
@@ -20,7 +20,7 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
late Future<bool> _isLoaded;
|
||||
|
||||
Future<bool> _loadProfile() async {
|
||||
User? userInfo = await User.fetchUser();
|
||||
User? userInfo = await User.getMe();
|
||||
|
||||
if (userInfo != null) {
|
||||
_userInfo = userInfo;
|
||||
@@ -108,7 +108,7 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
invites: _userInfo.homegroupInvites,
|
||||
onJoin: (id) async {
|
||||
User? response =
|
||||
await _userInfo.patch(homegroup: id);
|
||||
await _userInfo.patchMe(homegroup: id);
|
||||
|
||||
if (response != null) {
|
||||
setState(() {
|
||||
@@ -117,7 +117,7 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
}
|
||||
},
|
||||
onCreate: () async {
|
||||
String? name = await createHomegroupDialog(
|
||||
String? name = await textEntryDialog(
|
||||
context,
|
||||
"Create Homegroup",
|
||||
"Homegroup Name",
|
||||
@@ -132,14 +132,13 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
return;
|
||||
}
|
||||
|
||||
Homegroup? hg =
|
||||
await Homegroup.createHomegroup(name);
|
||||
Homegroup? hg = await Homegroup.create(name);
|
||||
if (hg == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
User? response =
|
||||
await _userInfo.patch(homegroup: hg.id);
|
||||
await _userInfo.patchMe(homegroup: hg.id);
|
||||
|
||||
if (response != null) {
|
||||
setState(() {
|
||||
|
||||
@@ -28,7 +28,7 @@ class _CreateJoinHomegroupState extends State<CreateJoinHomegroup> {
|
||||
|
||||
Future<bool> _loadInvites() async {
|
||||
for (int id in widget.invites) {
|
||||
Homegroup? hg = await Homegroup.fetchHomegroup(id);
|
||||
Homegroup? hg = await Homegroup.get(id);
|
||||
|
||||
if (hg != null) {
|
||||
_invitedGroups.add(hg);
|
||||
@@ -157,7 +157,7 @@ class _EditHomegroupState extends State<EditHomegroup> {
|
||||
Map<HomegroupInvite, SimpleUser> _groupInviteUsers = {};
|
||||
|
||||
Future<bool> _loadHomegroup() async {
|
||||
Homegroup? hg = await Homegroup.fetchHomegroup(widget.homegroupID);
|
||||
Homegroup? hg = await Homegroup.get(widget.homegroupID);
|
||||
if (hg == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ class _EditHomegroupState extends State<EditHomegroup> {
|
||||
_groupInviteUsers = {};
|
||||
|
||||
for (int id in hg.users) {
|
||||
SimpleUser? u = await SimpleUser.fetchUser(id: id);
|
||||
SimpleUser? u = await SimpleUser.get(id: id);
|
||||
|
||||
if (u != null) {
|
||||
_groupUsers.add(u);
|
||||
@@ -181,7 +181,7 @@ class _EditHomegroupState extends State<EditHomegroup> {
|
||||
continue;
|
||||
}
|
||||
|
||||
SimpleUser? u = await SimpleUser.fetchUser(id: invite.userID);
|
||||
SimpleUser? u = await SimpleUser.get(id: invite.userID);
|
||||
|
||||
if (u != null) {
|
||||
_groupInvites.add(invite);
|
||||
@@ -271,8 +271,8 @@ class _EditHomegroupState extends State<EditHomegroup> {
|
||||
user:
|
||||
_groupInviteUsers[_groupInvites[index]]!,
|
||||
onButton: (id) async {
|
||||
bool success = await _groupInvites[index]
|
||||
.deleteInvite();
|
||||
bool success =
|
||||
await _groupInvites[index].delete();
|
||||
if (success) {
|
||||
setState(() {
|
||||
_isLoaded = _loadHomegroup();
|
||||
@@ -304,7 +304,7 @@ class _EditHomegroupState extends State<EditHomegroup> {
|
||||
}
|
||||
|
||||
for (int id in selectedIDs) {
|
||||
await HomegroupInvite.createInvite(_homegroup!.id, id);
|
||||
await HomegroupInvite.create(_homegroup!.id, id);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:grocery_helper/api/models/homegroup.dart';
|
||||
import 'package:grocery_helper/api/models/ingredient.dart';
|
||||
import 'package:grocery_helper/api/models/recipe.dart';
|
||||
import 'package:grocery_helper/api/models/user.dart';
|
||||
import 'package:grocery_helper/pages/recipes_page/widgets/recipe_card_widget.dart';
|
||||
import 'package:grocery_helper/widgets/text_entry_dialog.dart';
|
||||
|
||||
class RecipesPage extends StatefulWidget {
|
||||
const RecipesPage({super.key});
|
||||
@@ -14,16 +15,15 @@ class RecipesPage extends StatefulWidget {
|
||||
class _RecipesPageState extends State<RecipesPage> {
|
||||
late Future<List<Recipe>> _recipes;
|
||||
late User _userInfo;
|
||||
late Homegroup _homegroup;
|
||||
|
||||
Future<List<Recipe>> _fetchList() async {
|
||||
User? userInfo = await User.fetchUser();
|
||||
User? userInfo = await User.getMe();
|
||||
if (userInfo == null || userInfo.homegroup == null) {
|
||||
return [];
|
||||
}
|
||||
_userInfo = userInfo;
|
||||
|
||||
List<Recipe> recipes = await Recipe.fetchList(_userInfo.homegroup!);
|
||||
List<Recipe> recipes = await Recipe.getList(_userInfo.homegroup!);
|
||||
return recipes;
|
||||
}
|
||||
|
||||
@@ -42,38 +42,87 @@ class _RecipesPageState extends State<RecipesPage> {
|
||||
return Text(snapshot.error.toString());
|
||||
} else if (snapshot.hasData &&
|
||||
snapshot.connectionState == ConnectionState.done) {
|
||||
return RecipeList(recipes: snapshot.data!);
|
||||
return RecipeList(
|
||||
recipes: snapshot.data!, homegroup: _userInfo.homegroup!);
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RecipeList extends StatelessWidget {
|
||||
class RecipeList extends StatefulWidget {
|
||||
final List<Recipe> recipes;
|
||||
const RecipeList({super.key, required this.recipes});
|
||||
final int homegroup;
|
||||
const RecipeList({super.key, required this.recipes, required this.homegroup});
|
||||
|
||||
@override
|
||||
State<RecipeList> createState() => _RecipeListState();
|
||||
}
|
||||
|
||||
class _RecipeListState extends State<RecipeList> {
|
||||
int? _expandedCard;
|
||||
|
||||
void showError(String text) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.error,
|
||||
content: Text(text),
|
||||
action: SnackBarAction(
|
||||
textColor: Theme.of(context).colorScheme.onError,
|
||||
label: "Dismiss",
|
||||
onPressed: () => ScaffoldMessenger.of(context).hideCurrentSnackBar(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
ListView.builder(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: recipes.length,
|
||||
itemBuilder: (context, index) =>
|
||||
RecipeCard(recipe: recipes[index])),
|
||||
ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: widget.recipes.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemBuilder: (context, index) => RecipeCard(
|
||||
recipe: widget.recipes[index],
|
||||
isExpanded: _expandedCard == index,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (_expandedCard == index) {
|
||||
_expandedCard = null;
|
||||
} else {
|
||||
_expandedCard = index;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: FloatingActionButton.extended(
|
||||
onPressed: () {},
|
||||
onPressed: () async {
|
||||
String? name =
|
||||
await textEntryDialog(context, "Recipe Name", "Recipe");
|
||||
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name == "") {
|
||||
showError("Recipe name cannot be empty");
|
||||
return;
|
||||
}
|
||||
|
||||
Recipe? created = await Recipe.create(name, widget.homegroup);
|
||||
},
|
||||
label: Row(
|
||||
children: const [Icon(Icons.note_add), Text("New Recipe")],
|
||||
),
|
||||
// child: const Icon(Icons.note_add),
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -81,78 +130,3 @@ class RecipeList extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RecipeCard extends StatelessWidget {
|
||||
final Recipe recipe;
|
||||
const RecipeCard({super.key, required this.recipe});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle ingredientStyle = Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge!
|
||||
.copyWith(color: Theme.of(context).colorScheme.onSurface);
|
||||
|
||||
return Card(
|
||||
elevation: 10,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(10), bottom: Radius.zero),
|
||||
),
|
||||
margin: EdgeInsets.zero,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
recipe.name,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: (recipe.ingredients.length / 2).ceil(),
|
||||
shrinkWrap: true,
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
if (recipe.ingredients.length % 2 == 0 ||
|
||||
index * 2 <= recipe.ingredients.length - 2) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
recipe.ingredients[index * 2].name,
|
||||
style: ingredientStyle,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(recipe.ingredients[index * 2 + 1].name,
|
||||
style: ingredientStyle),
|
||||
)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Row(
|
||||
children: [
|
||||
Text(recipe.ingredients[index * 2].name,
|
||||
style: ingredientStyle),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:grocery_helper/api/models/ingredient.dart';
|
||||
import 'package:grocery_helper/api/models/recipe.dart';
|
||||
import 'package:grocery_helper/theme.dart';
|
||||
import 'package:grocery_helper/widgets/text_entry_dialog.dart';
|
||||
|
||||
class RecipeCard extends StatelessWidget {
|
||||
final Recipe recipe;
|
||||
final bool isExpanded;
|
||||
final Function() onTap;
|
||||
const RecipeCard({
|
||||
super.key,
|
||||
required this.recipe,
|
||||
required this.isExpanded,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Card(
|
||||
elevation: 10,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: const Radius.circular(10),
|
||||
bottom: isExpanded ? Radius.zero : const Radius.circular(10)),
|
||||
),
|
||||
margin: EdgeInsets.zero,
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
recipe.name,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
),
|
||||
AnimatedRotation(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
turns: isExpanded ? 0.5 : 0,
|
||||
child: const Icon(Icons.expand_more, size: 30),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
AnimatedSize(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: isExpanded
|
||||
? IngredientSection(ingredients: recipe.ingredients)
|
||||
: const SizedBox(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
AnimatedSize(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: isExpanded
|
||||
? ElevatedButton(
|
||||
style: bottomButtonStyle,
|
||||
onPressed: () async {
|
||||
String? name = await textEntryDialog(
|
||||
context, "Ingredient Name", "Ingredient");
|
||||
},
|
||||
child: const Text("Add Ingredient"),
|
||||
)
|
||||
: const SizedBox(),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IngredientSection extends StatelessWidget {
|
||||
final List<Ingredient> ingredients;
|
||||
const IngredientSection({super.key, required this.ingredients});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle ingredientStyle = Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
.copyWith(color: Theme.of(context).colorScheme.onSurface);
|
||||
|
||||
return Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: (ingredients.length / 2).ceil(),
|
||||
shrinkWrap: true,
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: index % 2 == 0
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
if (ingredients.length % 2 == 0 ||
|
||||
index * 2 <= ingredients.length - 2) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
ingredients[index * 2].name,
|
||||
style: ingredientStyle,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(ingredients[index * 2 + 1].name,
|
||||
style: ingredientStyle),
|
||||
)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Row(
|
||||
children: [
|
||||
Text(ingredients[index * 2].name, style: ingredientStyle),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -15,59 +15,69 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Brightness brightness = Theme.of(context).colorScheme.brightness;
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
SizedBox.square(
|
||||
dimension: 200,
|
||||
child: SvgPicture.asset(
|
||||
brightness == Brightness.light
|
||||
? "assets/images/holes.svg"
|
||||
: "assets/images/holes-dark.svg",
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
FractionallySizedBox(
|
||||
widthFactor: 0.9,
|
||||
child: Card(
|
||||
elevation: 10,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
children: [
|
||||
LayoutBuilder(builder: (builder, constraints) {
|
||||
return ToggleButtons(
|
||||
isSelected: _isSelected,
|
||||
constraints: BoxConstraints.expand(
|
||||
width: constraints.maxWidth / 2 - 8,
|
||||
height: 30),
|
||||
selectedBorderColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
onPressed: (index) {
|
||||
setState(() {
|
||||
for (int i = 0; i < _isSelected.length; i++) {
|
||||
_isSelected[i] = (i == index);
|
||||
}
|
||||
});
|
||||
},
|
||||
children: const [Text("Log In"), Text("Sign Up")],
|
||||
);
|
||||
}),
|
||||
_isSelected[0] ? const LoginForm() : const SignupForm()
|
||||
],
|
||||
body: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints viewportContraints) {
|
||||
return SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints:
|
||||
BoxConstraints(minHeight: viewportContraints.maxHeight),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox.square(
|
||||
dimension: 150,
|
||||
child: SvgPicture.asset(
|
||||
"assets/images/desktop.svg",
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
FractionallySizedBox(
|
||||
widthFactor: 0.9,
|
||||
child: Card(
|
||||
elevation: 10,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
children: [
|
||||
LayoutBuilder(builder: (builder, constraints) {
|
||||
return ToggleButtons(
|
||||
isSelected: _isSelected,
|
||||
constraints: BoxConstraints.expand(
|
||||
width: constraints.maxWidth / 2 - 8,
|
||||
height: 30),
|
||||
selectedBorderColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
onPressed: (index) {
|
||||
setState(() {
|
||||
for (int i = 0;
|
||||
i < _isSelected.length;
|
||||
i++) {
|
||||
_isSelected[i] = (i == index);
|
||||
}
|
||||
});
|
||||
},
|
||||
children: const [
|
||||
Text("Log In"),
|
||||
Text("Sign Up")
|
||||
],
|
||||
);
|
||||
}),
|
||||
_isSelected[0]
|
||||
? const LoginForm()
|
||||
: const SignupForm()
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class _TextEntryFormState extends State<TextEntryForm> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> createHomegroupDialog(
|
||||
Future<String?> textEntryDialog(
|
||||
BuildContext context, String title, String label,
|
||||
{String? defaultValue}) async {
|
||||
String? name = await showDialog(
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "16x16",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_16.png",
|
||||
"scale" : "1x"
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
},
|
||||
{
|
||||
"size" : "16x16",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_32.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "32x32",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "32x32",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_64.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "128x128",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_128.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "128x128",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_256.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_256.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_512.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_512.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "app_icon_1024.png",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
"images": [
|
||||
{
|
||||
"size": "16x16",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_16.png",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "16x16",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_32.png",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_32.png",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_64.png",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_128.png",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_256.png",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_256.png",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_512.png",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_512.png",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"idiom": "mac",
|
||||
"filename": "app_icon_1024.png",
|
||||
"scale": "2x"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 780 B |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 4.8 KiB |
@@ -131,7 +131,7 @@ packages:
|
||||
name: flutter_secure_storage
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.0"
|
||||
version: "6.1.0"
|
||||
flutter_secure_storage_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -60,6 +60,13 @@ flutter_icons:
|
||||
android: true
|
||||
ios: true
|
||||
image_path: "assets/icons/icon.png"
|
||||
windows:
|
||||
generate: true
|
||||
image_path: "assets/icons/desktop.png"
|
||||
icon_size: 256
|
||||
macos:
|
||||
generate: true
|
||||
image_path: "assets/icons/desktop.png"
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 19 KiB |