This repository has been archived by the owner on Jan 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add collection model and api endpoint, #2
- Loading branch information
Showing
11 changed files
with
2,996 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "5b7fb4f6-2969-4c31-9ff0-f8d31c9dae97", | ||
"name": "Panoramax", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | ||
}, | ||
"item": [ | ||
{ | ||
"name": "Get Collections", | ||
"request": { | ||
"method": "GET", | ||
"header": [], | ||
"url": { | ||
"raw": "http://localhost:5000/api/collections?", | ||
"protocol": "http", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "5000", | ||
"path": [ | ||
"api", | ||
"collections" | ||
], | ||
"query": [ | ||
{ | ||
"key": "", | ||
"value": null | ||
} | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Create Collection", | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\r\n \"title\": \"FirstCollection\"\r\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "http://localhost:5000/api/collections", | ||
"protocol": "http", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "5000", | ||
"path": [ | ||
"api", | ||
"collections" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Post picture to Collection", | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"body": { | ||
"mode": "formdata", | ||
"formdata": [ | ||
{ | ||
"key": "isBlurred", | ||
"value": "false", | ||
"type": "default" | ||
}, | ||
{ | ||
"key": "position", | ||
"value": "1", | ||
"type": "default" | ||
}, | ||
{ | ||
"key": "picture", | ||
"type": "file", | ||
"src": "/C:/Workspace/Nobelisation/panoramax_mobile/test/pictures/background-beautiful-blossom-calm-waters-268533.jpg" | ||
} | ||
] | ||
}, | ||
"url": { | ||
"raw": "http://localhost:5000/api/collections/77d0424b-d87b-47a9-a935-03253cb1c111/items", | ||
"protocol": "http", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "5000", | ||
"path": [ | ||
"api", | ||
"collections", | ||
"77d0424b-d87b-47a9-a935-03253cb1c111", | ||
"items" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
] | ||
} |
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,93 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../service/api/api.dart'; | ||
|
||
class HomePage extends StatefulWidget { | ||
const HomePage({super.key, required this.title}); | ||
|
||
// This widget is the home page of your application. It is stateful, meaning | ||
// that it has a State object (defined below) that contains fields that affect | ||
// how it looks. | ||
|
||
// This class is the configuration for the state. It holds the values (in this | ||
// case the title) provided by the parent (in this case the App widget) and | ||
// used by the build method of the State. Fields in a Widget subclass are | ||
// always marked "final". | ||
|
||
final String title; | ||
|
||
@override | ||
State<HomePage> createState() => _HomePageState(); | ||
} | ||
|
||
class _HomePageState extends State<HomePage> { | ||
int _counter = 0; | ||
CollectionsApi collectionsApi = CollectionsApi(); | ||
|
||
Future<void> _incrementCounter() async { | ||
print(await collectionsApi.apiCollectionsGet()); | ||
setState(() { | ||
// This call to setState tells the Flutter framework that something has | ||
// changed in this State, which causes it to rerun the build method below | ||
// so that the display can reflect the updated values. If we changed | ||
// _counter without calling setState(), then the build method would not be | ||
// called again, and so nothing would appear to happen. | ||
_counter++; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
// This method is rerun every time setState is called, for instance as done | ||
// by the _incrementCounter method above. | ||
// | ||
// The Flutter framework has been optimized to make rerunning build methods | ||
// fast, so that you can just rebuild anything that needs updating rather | ||
// than having to individually change instances of widgets. | ||
return Scaffold( | ||
appBar: AppBar( | ||
// TRY THIS: Try changing the color here to a specific color (to | ||
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar | ||
// change color while the other colors stay the same. | ||
backgroundColor: Theme.of(context).colorScheme.inversePrimary, | ||
// Here we take the value from the MyHomePage object that was created by | ||
// the App.build method, and use it to set our appbar title. | ||
title: Text(widget.title), | ||
), | ||
body: Center( | ||
// Center is a layout widget. It takes a single child and positions it | ||
// in the middle of the parent. | ||
child: Column( | ||
// Column is also a layout widget. It takes a list of children and | ||
// arranges them vertically. By default, it sizes itself to fit its | ||
// children horizontally, and tries to be as tall as its parent. | ||
// | ||
// Column has various properties to control how it sizes itself and | ||
// how it positions its children. Here we use mainAxisAlignment to | ||
// center the children vertically; the main axis here is the vertical | ||
// axis because Columns are vertical (the cross axis would be | ||
// horizontal). | ||
// | ||
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" | ||
// action in the IDE, or press "p" in the console), to see the | ||
// wireframe for each widget. | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
const Text( | ||
'You have pushed the button this many times:', | ||
), | ||
Text( | ||
'$_counter', | ||
style: Theme.of(context).textTheme.headlineMedium, | ||
), | ||
], | ||
), | ||
), | ||
floatingActionButton: FloatingActionButton( | ||
onPressed: _incrementCounter, | ||
tooltip: 'Increment', | ||
child: const Icon(Icons.add), | ||
), // This trailing comma makes auto-formatting nicer for build methods. | ||
); | ||
} | ||
} |
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,11 @@ | ||
library panoramax.api; | ||
|
||
import 'dart:async'; | ||
import 'package:http/http.dart' as http; | ||
import 'dart:convert'; | ||
import 'model/geo_visio.dart'; | ||
|
||
part 'endpoint/collections_api.dart'; | ||
|
||
const String API_HOSTNAME = '10.0.2.2:5000'; | ||
const bool API_IS_HTTPS = false; |
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,41 @@ | ||
part of panoramax.api; | ||
|
||
class CollectionsApi { | ||
/// | ||
/// List available collections | ||
/// | ||
Future<GeoVisioCollections?> apiCollectionsGet({ int? limit, String? format, List<int>? bbox, String? filter, String? datetime }) async { | ||
// query params | ||
Map<String, String> queryParams = {}; | ||
if(limit != null) { | ||
queryParams.putIfAbsent("limit", limit as String Function()); | ||
} | ||
if(format != null) { | ||
queryParams.putIfAbsent("format", format as String Function()); | ||
} | ||
if(bbox != null) { | ||
queryParams.putIfAbsent("bbox", bbox as String Function()); | ||
} | ||
if(filter != null) { | ||
queryParams.putIfAbsent("filter", filter as String Function()); | ||
} | ||
if(datetime != null) { | ||
queryParams.putIfAbsent("datetime", datetime as String Function()); | ||
} | ||
|
||
// create path and map variables | ||
var url = API_IS_HTTPS ? | ||
Uri.https(API_HOSTNAME, '/api/collections', queryParams) : | ||
Uri.http(API_HOSTNAME, '/api/collections', queryParams); | ||
|
||
var response = await http.get(url); | ||
if(response.statusCode >= 400) { | ||
throw new Exception(response.statusCode/* + response.body*/); | ||
} else if(response.body != null) { | ||
return | ||
GeoVisioCollections.fromJson(json.decode(response.body)); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.