Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
feat: refactoring collection creation, #4
Browse files Browse the repository at this point in the history
  • Loading branch information
luifr10 committed Mar 3, 2024
1 parent 99dba2f commit 450d2d1
Show file tree
Hide file tree
Showing 23 changed files with 416 additions and 124 deletions.
81 changes: 77 additions & 4 deletions Panoramax.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,23 @@
},
{
"name": "Create Collection",
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"content-type": true
}
},
"request": {
"method": "POST",
"header": [],
"header": [
{
"key": "Content-Type",
"value": "application/json;charset=uft8",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"title\": \"FirstCollection\"\r\n}",
"raw": "{\r\n \"title\": \"Anoth+er --\"\r\n}",
"options": {
"raw": {
"language": "json"
Expand All @@ -60,6 +71,47 @@
},
"response": []
},
{
"name": "API info",
"protocolProfileBehavior": {
"disableBodyPruning": true,
"disabledSystemHeaders": {
"content-type": true
}
},
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json;charset=uft8",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"title\": \"Another --\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:5000/api/",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
""
]
}
},
"response": []
},
{
"name": "Post picture to Collection",
"request": {
Expand All @@ -86,7 +138,7 @@
]
},
"url": {
"raw": "http://localhost:5000/api/collections/77d0424b-d87b-47a9-a935-03253cb1c111/items",
"raw": "http://localhost:5000/api/collections/7ed76872-2580-4a7b-95cd-afb6bc23229c/items",
"protocol": "http",
"host": [
"localhost"
Expand All @@ -95,12 +147,33 @@
"path": [
"api",
"collections",
"77d0424b-d87b-47a9-a935-03253cb1c111",
"7ed76872-2580-4a7b-95cd-afb6bc23229c",
"items"
]
}
},
"response": []
},
{
"name": "Get Collection",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:5000/api/collections/77d0424b-d87b-47a9-a935-03253cb1c111",
"protocol": "http",
"host": [
"localhost"
],
"port": "5000",
"path": [
"api",
"collections",
"77d0424b-d87b-47a9-a935-03253cb1c111"
]
}
},
"response": []
}
]
}
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ samples, guidance on mobile development, and a full API reference.
docker-compose up -d
```

### Redirect WSL port (Only for docker WSL)
```shell
netsh interface portproxy add v4tov4 listenport=5000 listenaddress=0.0.0.0 connectport=5000 connectaddress=<your-wsl-ip>
```
To retrieve <your-wsl-ip> execute the following command from your wsl machine :
```shell
ip add | grep "eth0
```
### Generating translation
```shell
dart run build_runner build
flutter clean
flutter pub get
```
5 changes: 4 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<application
android:label="panoramax_mobile"
android:name="${applicationName}"
Expand Down
5 changes: 5 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
targets:
$default:
builders:
uuv_flutter|generateTests:
options:
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
backend:
image: geovisio/api:latest
image: geovisio/api:2.4.0
command: api
volumes:
- pic_data:/data/geovisio
Expand Down
5 changes: 5 additions & 0 deletions features/counter.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Counter
The counter should be incremented when the button is pressed.

Scenario: Counter increases when the button is pressed
When I tap the "increment" button 10 times
4 changes: 3 additions & 1 deletion lib/component/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ part of panoramax;
PreferredSizeWidget PanoramaxAppBar({context, title = "Panoramax"}) {
return AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(title),
title: Text(
title
),
);
}
2 changes: 1 addition & 1 deletion lib/component/collection_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CollectionPreview extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
DATE_FORMATTER.format(DateTime.parse(
DateFormat(DATE_FORMATTER).format(DateTime.parse(
collection.updated != null ?
collection.updated! :
collection.created
Expand Down
16 changes: 12 additions & 4 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"newSequenceNameField": "Name",
"newSequenceNameField_placeholder": "Enter the new sequence name",
"newSequenceSendButton": "Send",
"yourSequence": "Your sequences",
"element": "element(s)",
"createSequence_tooltip": "Create a new sequence"
"createSequence_tooltip": "Create a new sequence",
"unknownError": "Oops ! An error occured...",
"emptyError": "No element found",
"loading": "Loading...",

"capture": "Take a picture",
"switchCamera": "Switch camera",
"createSequenceWithPicture_tooltip": "Create a new sequence with captured pictures",

"newSequenceNameField": "Name",
"newSequenceNameField_placeholder": "Enter the new sequence name",
"newSequenceSendButton": "Send"
}
16 changes: 12 additions & 4 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"newSequenceNameField": "Nom",
"newSequenceNameField_placeholder": "Saisissez le nom de la nouvelle séquence",
"newSequenceSendButton": "Envoyer",
"yourSequence": "Vos séquences",
"element": "élément(s)",
"createSequence_tooltip": "Créer une nouvelle séquence"
"createSequence_tooltip": "Créer une nouvelle séquence",
"unknownError": "Oops ! Une erreur s'est produite...",
"emptyError": "Aucun élément trouvé",
"loading": "Chargement...",

"capture": "Prendre la une photo",
"switchCamera": "Changer de camera",
"createSequenceWithPicture_tooltip": "Créer une nouvelle séquence avec les photos prises",

"newSequenceNameField": "Nom",
"newSequenceNameField_placeholder": "Saisissez le nom de la nouvelle séquence",
"newSequenceSendButton": "Envoyer"
}
21 changes: 11 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ library panoramax;
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
import 'package:flutter/services.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_exif_plugin/flutter_exif_plugin.dart';
import 'package:geolocator/geolocator.dart';
Expand All @@ -12,36 +11,38 @@ import 'package:panoramax_mobile/service/api/model/geo_visio.dart';
import 'package:intl/intl.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'dart:ui';
import 'package:badges/badges.dart' as badges;
import 'package:equatable/equatable.dart';
import 'package:go_router/go_router.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:loading_btn/loading_btn.dart';

import '../service/api/api.dart';
import 'service/api/api.dart';

part 'component/app_bar.dart';
part 'component/collection_preview.dart';
part 'page/homepage.dart';
part 'page/capture_page.dart';
part 'page/collection_creation_page.dart';
part 'service/routing.dart';


final DateFormat DATE_FORMATTER = DateFormat.yMd();
final String DATE_FORMATTER = 'dd/MM/y HH:mm:ss';

void main() {
runApp(const MyApp());
runApp(const PanoramaxApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});
class PanoramaxApp extends StatelessWidget {
const PanoramaxApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
return MaterialApp.router(
title: 'Panoramax',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo),
useMaterial3: true,
),
localizationsDelegates: const [
Expand All @@ -54,7 +55,7 @@ class MyApp extends StatelessWidget {
Locale('en'),
Locale('fr'),
],
home: const HomePage(),
routerConfig: _router
);
}
}
Expand Down
21 changes: 10 additions & 11 deletions lib/page/capture_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ class _CapturePageState extends State<CapturePage> {
initCamera(widget.cameras![0]);
}

Future goToCollectionCreationPage(){
return Navigator.push(context,
MaterialPageRoute(builder: (_) => CollectionCreationPage(imgList: _imgListCaptured))
);
void goToCollectionCreationPage(){
context.push(Routes.newSequenceSend, extra: _imgListCaptured);
}

Future takePicture() async {
Expand All @@ -43,10 +41,6 @@ class _CapturePageState extends State<CapturePage> {
await _cameraController.setFlashMode(FlashMode.off);
final XFile rawImage = await _cameraController.takePicture();
debugPrint(rawImage.path);
File imageFile = File(rawImage.path);

int currentUnix = DateTime.now().millisecondsSinceEpoch;
String fileFormat = imageFile.path.split('.').last;

bool storagePermission = await Permission.storage.isGranted;
bool mediaPermission = await Permission.accessMediaLocation.isGranted;
Expand All @@ -70,7 +64,7 @@ class _CapturePageState extends State<CapturePage> {
locationPermission = (await Permission.location.request()).isGranted;
}

bool isPermissionGranted = storagePermission && mediaPermission && manageExternalStoragePermission;
bool isPermissionGranted = locationPermission && mediaPermission && manageExternalStoragePermission;

if (isPermissionGranted) {
final exif = FlutterExif.fromPath(rawImage.path);
Expand All @@ -79,7 +73,8 @@ class _CapturePageState extends State<CapturePage> {
await exif.setAltitude(currentLocation.altitude);
await exif.saveAttributes();
setState(() {
_imgListCaptured.add(new File(rawImage.path));
var capturedPicture = new File(rawImage.path);
_imgListCaptured.add(capturedPicture);
});
} else {
throw Exception("No permission to move file");
Expand All @@ -98,6 +93,7 @@ class _CapturePageState extends State<CapturePage> {
if (!mounted) return;
setState(() {});
});
await _cameraController.setFocusMode(FocusMode.locked);
} on CameraException catch (e) {
debugPrint("camera error $e");
}
Expand Down Expand Up @@ -136,6 +132,7 @@ class _CapturePageState extends State<CapturePage> {
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
icon: const Icon(Icons.circle_outlined, color: Colors.white),
tooltip: AppLocalizations.of(context)!.capture
)),
]),
)
Expand All @@ -162,7 +159,8 @@ class _CapturePageState extends State<CapturePage> {
() => _isRearCameraSelected = !_isRearCameraSelected);
initCamera(widget.cameras![_isRearCameraSelected ? 0 : 1]);
},
)),
tooltip: AppLocalizations.of(context)!.switchCamera
)),
_imgListCaptured.length > 0 ? badges.Badge(
badgeContent: Text('${_imgListCaptured.length}'),
child: cartIcon,
Expand All @@ -174,6 +172,7 @@ class _CapturePageState extends State<CapturePage> {
icon: Icon(Icons.send_outlined,
color: Colors.white),
onPressed: goToCollectionCreationPage,
tooltip: AppLocalizations.of(context)!.createSequenceWithPicture_tooltip
)),
]),
)
Expand Down
Loading

0 comments on commit 450d2d1

Please sign in to comment.