-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/post content #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emmanuelCode
wants to merge
11
commits into
main
Choose a base branch
from
feature/post_content
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f69c8ad
fix: running on android device and update dependencies
emmanuelCode b12caee
chore: wip, add modal sheet layout and image picker
emmanuelCode 7a33d9f
chore: wip, update add post prototype and small fix
emmanuelCode ded4d0f
chore: setup firebase storage emulator
emmanuelCode 1dba834
chore: add firebase storage and prototype implementation in modal layout
emmanuelCode dad115c
fix: add SafeArea under Scaffold for device ui
emmanuelCode eb60fae
docs: update README.md
emmanuelCode edb1d74
chore: add translation and update layout
emmanuelCode 358e22a
fix: update host and remove auto mapping
emmanuelCode 4e41554
docs: update README.md
emmanuelCode 3824e3d
chore: change relative import to package import
emmanuelCode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| { | ||
| "@@locale": "en", | ||
| "whatsUpIn": "What's up in", | ||
| "montreal": "Montréal" | ||
| "montreal": "Montreal", | ||
| "add":"Add", | ||
| "title":"title", | ||
| "upload":"Upload", | ||
| "selectPicture":"Select Picture", | ||
| "or":"OR", | ||
| "takePicture": "Take Picture" | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| { | ||
| "@@locale": "fr", | ||
| "whatsUpIn": "Quoi de neuf à", | ||
| "montreal": "Montréal" | ||
| "montreal": "Montréal", | ||
| "add": "Ajouter", | ||
| "title":"titre", | ||
| "upload":"Téléverser", | ||
| "selectPicture":"Choisir une Image", | ||
| "or":"OU", | ||
| "takePicture":"Prendre une Photo" | ||
| } |
This file contains hidden or 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
201 changes: 201 additions & 0 deletions
201
lib/presentation/components/src/add_post_modal_sheet.dart
This file contains hidden or 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,201 @@ | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:firebase_storage/firebase_storage.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:image_picker/image_picker.dart'; | ||
| import 'package:instreal/features/posts/post_entity.dart'; | ||
| import 'package:instreal/l10n/index.dart'; | ||
|
|
||
|
|
||
| class AddPostModalPage extends StatefulWidget { | ||
| final Reference storageRef; | ||
| const AddPostModalPage({required this.storageRef, super.key}); | ||
|
|
||
| @override | ||
| State<AddPostModalPage> createState() => _AddPostModalPageState(); | ||
| } | ||
|
|
||
| class _AddPostModalPageState extends State<AddPostModalPage> { | ||
| XFile? image; | ||
| final ImagePicker picker = ImagePicker(); | ||
| final TextEditingController textEditName = TextEditingController(); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Padding( | ||
| padding: const EdgeInsets.all(16.0), | ||
| child: Column( | ||
| children: [ | ||
| Row( | ||
| children: [ | ||
| Text(InstrealLocalizations.of(context)!.add), | ||
| const Spacer(), | ||
| const Align( | ||
| alignment: Alignment.centerRight, child: CloseButton()), | ||
| ], | ||
| ), | ||
| const SizedBox(height: 8), | ||
| if (image != null) | ||
| ImageView( | ||
| imagePath: image!.path, | ||
| onPressedRemoveImage: () { | ||
| image = null; | ||
| setState(() {/*Remove Image*/}); | ||
| }, | ||
| ) | ||
| else | ||
| ImagePickerView( | ||
| onPressedCamera: () async { | ||
| image = await picker.pickImage(source: ImageSource.camera); | ||
| setState(() {/*Update Image*/}); | ||
| }, | ||
| onPressedGallery: () async { | ||
| image = await picker.pickImage(source: ImageSource.gallery); | ||
| setState(() {/*Update Image*/}); | ||
| }, | ||
| ), | ||
| TextField( | ||
| decoration: InputDecoration( | ||
| label: Text(InstrealLocalizations.of(context)!.title), | ||
| ), | ||
| controller: textEditName, | ||
| ), | ||
| const SizedBox(height: 16), | ||
| Row( | ||
| children: [ | ||
| OutlinedButton( | ||
| onPressed: () async { | ||
| final storage = | ||
| widget.storageRef.child('images/instreal.jpg'); | ||
|
|
||
| late String fileUrl; | ||
| //TODO may need a proper implementation | ||
|
|
||
| try { | ||
| await storage.putFile(File(image!.path)); | ||
| fileUrl = await storage.getDownloadURL(); | ||
| } on FirebaseException catch (e) { | ||
| debugPrint(e.message); | ||
| } | ||
|
|
||
| if (context.mounted) { | ||
| Navigator.pop( | ||
| context, | ||
| Post( | ||
| id: '', | ||
| title: textEditName.text, | ||
| author: 'author', // get name from firebase auth V3 | ||
| imageUrl: fileUrl, | ||
| ), | ||
| ); | ||
| } | ||
| }, | ||
| child: Text(InstrealLocalizations.of(context)!.upload)), | ||
| //add loading indicator when uploading | ||
| ], | ||
| ) | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class ImagePickerView extends StatelessWidget { | ||
| final double? iconSize = 96; | ||
| final VoidCallback onPressedCamera; | ||
| final VoidCallback onPressedGallery; | ||
|
|
||
| const ImagePickerView({ | ||
| required this.onPressedCamera, | ||
| required this.onPressedGallery, | ||
| super.key, | ||
| }); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return AspectRatio( | ||
| aspectRatio: 4 / 3, | ||
| child: DecoratedBox( | ||
| decoration: BoxDecoration( | ||
| borderRadius: BorderRadius.circular(16.0), | ||
| border: Border.all( | ||
| color: Colors.grey, | ||
| style: BorderStyle.solid, | ||
| ), | ||
| ), | ||
| child: Row( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: [ | ||
| Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: [ | ||
| IconButton.outlined( | ||
| padding: const EdgeInsets.all(16), | ||
| onPressed: onPressedGallery, | ||
| icon: Icon( | ||
| Icons.photo, | ||
| size: iconSize, | ||
| ), | ||
| ), | ||
| Text(InstrealLocalizations.of(context)!.selectPicture) | ||
| ], | ||
| ), | ||
| Padding( | ||
| padding: const EdgeInsets.symmetric(horizontal: 8), | ||
| child: Text(InstrealLocalizations.of(context)!.or)), | ||
| Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: [ | ||
| IconButton.outlined( | ||
| padding: const EdgeInsets.all(16), | ||
| onPressed: onPressedCamera, | ||
| icon: Icon( | ||
| Icons.photo_camera, | ||
| size: iconSize, | ||
| ), | ||
| ), | ||
| Text(InstrealLocalizations.of(context)!.takePicture) | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class ImageView extends StatelessWidget { | ||
| final VoidCallback onPressedRemoveImage; | ||
| final String imagePath; | ||
| const ImageView({ | ||
| required this.imagePath, | ||
| required this.onPressedRemoveImage, | ||
| super.key, | ||
| }); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return AspectRatio( | ||
| aspectRatio: 4 / 3, | ||
| child: ClipRRect( | ||
| borderRadius: BorderRadius.circular(16.0), | ||
| child: Stack( | ||
| fit: StackFit.expand, | ||
| children: [ | ||
| Image.file( | ||
| File(imagePath), | ||
| fit: BoxFit.cover, | ||
| ), | ||
| Align( | ||
| alignment: Alignment.bottomRight, | ||
| child: IconButton( | ||
| onPressed: onPressedRemoveImage, | ||
| icon: const Icon(Icons.delete), | ||
| ), | ||
| ) | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally it should be required since it is supposed to be automatic.