Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
#49 Add "open in browser" to recipe detail
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomate committed Dec 15, 2023
1 parent b26b372 commit 141e3bc
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 12 deletions.
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
<application
android:label="Untare"
Expand Down
12 changes: 12 additions & 0 deletions lib/components/widgets/bottom_sheets/recipe_more_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:untare/components/dialogs/delete_recipe_dialog.dart';
import 'package:untare/components/dialogs/upsert_meal_plan_entry_dialog.dart';
import 'package:untare/models/recipe.dart';
import 'package:untare/pages/recipe_upsert_page.dart';
import 'package:url_launcher/url_launcher.dart';

Widget buildRecipeMore(BuildContext context, BuildContext btsContext, Recipe recipe) {
RecipeBloc recipeBloc = BlocProvider.of<RecipeBloc>(context);
Expand All @@ -17,6 +18,17 @@ Widget buildRecipeMore(BuildContext context, BuildContext btsContext, Recipe rec
padding: const EdgeInsets.only(left: 12, right: 12, bottom: 6),
child: Column(
children: [
if (recipe.sourceUrl != null)
ListTile(
minLeadingWidth: 35,
enabled: (recipe.sourceUrl != null),
onTap: () {
launchUrl(Uri.parse(recipe.sourceUrl!));
Navigator.pop(btsContext);
},
leading: const Icon(Icons.open_in_browser_outlined),
title: Text(AppLocalizations.of(context)!.openInBrowser),
),
ListTile(
minLeadingWidth: 35,
onTap: () {
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/app_da.arb
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,6 @@
"timeInMinutes": "Tid i minutter",
"share": "Del",
"plural": "Flertal",
"useFractions": "Brug brøker"
"useFractions": "Brug brøker",
"openInBrowser": "Åbn i browser"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,6 @@
"editTime": "Zeit ändern",
"timeInMinutes": "Zeit in Minuten",
"share": "Teilen",
"useFractions": "Brüche verwenden"
"useFractions": "Brüche verwenden",
"openInBrowser": "Im Browser öffnen"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,6 @@
"editTime": "Edit time",
"timeInMinutes": "Time in minutes",
"share": "Share",
"useFractions": "Use fractions"
"useFractions": "Use fractions",
"openInBrowser": "Open in Browser"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,6 @@
"timeInMinutes": "Temps en minutes",
"share": "Partager",
"plural": "Pluriel",
"useFractions": "Utiliser des fractions"
"useFractions": "Utiliser des fractions",
"openInBrowser": "Ouvrir dans le navigateur"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_nl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,6 @@
"timeInMinutes": "Tijd in minuten",
"share": "Deel",
"plural": "Meervoud",
"useFractions": "Gebruik fracties"
"useFractions": "Gebruik fracties",
"openInBrowser": "Openen in browser"
}
17 changes: 12 additions & 5 deletions lib/models/recipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Recipe {
final bool? isNew;
@HiveField(17)
final int? recent;
@HiveField(18)
final String? sourceUrl;

Recipe({
this.id,
Expand All @@ -62,7 +64,8 @@ class Recipe {
this.rating,
this.lastCooked,
this.isNew,
this.recent
this.recent,
this.sourceUrl
});

Recipe copyWith({
Expand All @@ -83,7 +86,8 @@ class Recipe {
int? rating,
String? lastCooked,
bool? isNew,
int? recent
int? recent,
String? sourceUrl
}) {
return Recipe(
id: id ?? this.id,
Expand All @@ -103,7 +107,8 @@ class Recipe {
rating: rating ?? this.rating,
lastCooked: lastCooked ?? this.lastCooked,
isNew: isNew ?? this.isNew,
recent: recent ?? this.recent
recent: recent ?? this.recent,
sourceUrl: sourceUrl ?? this.sourceUrl
);
}

Expand Down Expand Up @@ -141,7 +146,8 @@ class Recipe {
'rating': rating,
'last_cooked': lastCooked,
'is_new': isNew,
'recent': recent
'recent': recent,
'source_url': sourceUrl
};
}

Expand All @@ -164,7 +170,8 @@ class Recipe {
rating: (json['rating'] is int) ? json['rating'] : ((json['rating'] is double) ? json['rating'].toInt() : null),
lastCooked: json['last_cooked'] as String?,
isNew: json['new'] as bool?,
recent: json['recent'] as int?
recent: json['recent'] as int?,
sourceUrl: json['source_url'] as String?,
);
}
}
7 changes: 5 additions & 2 deletions lib/models/recipe.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 141e3bc

Please sign in to comment.