-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat add cocktail row action dialog and more cocktails (#411)
* feat: add cocktail list item action dialog on long press * fix * chore: add cocktail * chore: more cocktails
- Loading branch information
1 parent
6dea0f1
commit 0bda4c7
Showing
22 changed files
with
194 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template class="block"> | ||
<button click.delegate="copyToClipboard()" class="btn w-full" data-cy="copy-to-clipboard-button"> | ||
<p if.bind="!textCopied" t="copy-name-to-clipboard"></p> | ||
<p else class="text-success" t="copied-to-clipboard"></p> | ||
<icon-clipboard class="h-6 w-6 ${textCopied ? 'text-success' : ''}"></icon-clipboard> | ||
</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { autoinject, bindable } from 'aurelia-framework'; | ||
import { Clipboard } from '@capacitor/clipboard'; | ||
@autoinject | ||
export class CopyToClipboard { | ||
@bindable public name: string; | ||
public textCopied = false; | ||
|
||
async copyToClipboard() { | ||
if (this.textCopied === true) { | ||
return; | ||
} | ||
|
||
await Clipboard.write({ | ||
string: this.name | ||
}); | ||
|
||
this.textCopied = true; | ||
|
||
setTimeout(() => { | ||
this.textCopied = false; | ||
}, 3000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/modules/cocktails/dialogs/manage-cocktail-row-dialog.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<template> | ||
<ux-dialog class="small-dialog" data-cy="manage-cocktail-row-dialog"> | ||
<div click.delegate="cancel()"> | ||
<div click.delegate="$event.stopPropagation()" class="bg-base-100 modal-box relative m-auto p-4"> | ||
<label class="btn btn-sm btn-circle absolute right-2 top-2" click.trigger="cancel()">✕</label> | ||
<h3 class="text-lg font-bold">${cocktail.name}</h3> | ||
<p if.bind="showBarName" class="text-sm text-base-content text-opacity-75">${barName}</p> | ||
|
||
<div class="divider mt-2"></div> | ||
|
||
<button click.delegate="toggleIsFavorite()" class="btn w-full" data-cy="toggle-favorite-button"> | ||
<p if.bind="cocktail.isFavorite" t="remove-from-favorites"></p> | ||
<p else t="add-to-favorites"></p> | ||
<icon-heart | ||
class="h-6 w-6 ${cocktail.isFavorite ? 'text-error fill-error' : 'fill-none'}"></icon-heart> | ||
</button> | ||
|
||
<copy-to-clipboard class="mt-4" name.bind="cocktail.name"></copy-to-clipboard> | ||
</div> | ||
</div> | ||
</ux-dialog> | ||
</template> |
37 changes: 37 additions & 0 deletions
37
src/modules/cocktails/dialogs/manage-cocktail-row-dialog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { DialogController } from 'aurelia-dialog'; | ||
import { autoinject } from 'aurelia-framework'; | ||
import { Cocktail } from 'domain/entities/cocktail'; | ||
import { CocktailService } from 'services/cocktail-service'; | ||
import { LocalStorageService } from 'services/local-storage-service'; | ||
|
||
@autoinject | ||
export class ManageCocktailRowDialog { | ||
public cocktail: Cocktail; | ||
public barName: string; | ||
public showBarName: boolean; | ||
constructor( | ||
private dialogController: DialogController, | ||
private localStorageService: LocalStorageService, | ||
private cocktailService: CocktailService | ||
) {} | ||
|
||
activate(request: Cocktail) { | ||
this.cocktail = request; | ||
this.barName = this.localStorageService.getIngredientList().name; | ||
this.showBarName = this.localStorageService.getIngredientLists().length > 1; | ||
} | ||
|
||
cancel() { | ||
this.dialogController.cancel(); | ||
} | ||
|
||
async toggleIsFavorite() { | ||
this.cocktail.isFavorite = !this.cocktail.isFavorite; | ||
|
||
if (this.cocktail.id.includes('x-')) { | ||
await this.cocktailService.updateCocktail(this.cocktail); | ||
} else { | ||
await this.cocktailService.updateCocktailInformation(this.cocktail); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.