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
<!-- Google Sign-in Section --> | |
<key>CFBundleURLTypes</key> | |
<array> | |
<dict> | |
<key>CFBundleTypeRole</key> | |
<string>Editor</string> | |
<key>CFBundleURLSchemes</key> | |
<array> | |
<string>COPY_REVERSE_CLIENT_ID_HERE</string> | |
</array> |
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
Future<void> _createTrip(BuildContext context) async { | |
// Display the loading indicator. | |
setState(() => _isLoading = true); | |
await ScopedModel.of<PhotosLibraryApiModel>(context) | |
.createAlbum(tripNameFormController.text) | |
.then((Album album) { | |
// Hide the loading indicator. | |
setState(() => _isLoading = 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
Future<Album> createAlbum(String title) async { | |
return client | |
.createAlbum(CreateAlbumRequest.fromTitle(title)) | |
.then((Album album) { | |
updateAlbums(); | |
return album; | |
}); | |
} |
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
Future<Album> createAlbum(CreateAlbumRequest request) async { | |
return http | |
.post( | |
'https://photoslibrary.googleapis.com/v1/albums', | |
body: jsonEncode(request), | |
headers: await _authHeaders, | |
) | |
.then( | |
(Response response) { | |
if (response.statusCode != 200) { |
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
Future<ListAlbumsResponse> listAlbums() async { | |
return http | |
.get( | |
'https://photoslibrary.googleapis.com/v1/albums?' | |
'excludeNonAppCreatedData=true&pageSize=50', | |
headers: await _authHeaders) | |
... | |
} |
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
Future _getImage(BuildContext context) async { | |
// Use the image_picker package to prompt the user for a photo from their | |
// device. | |
final File image = await ImagePicker.pickImage( | |
source: ImageSource.camera, | |
); | |
// Store the image that was selected. | |
setState(() { | |
_image = image; |
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
Future<String> uploadMediaItem(File image) async { | |
// Get the filename of the image | |
final String filename = path.basename(image.path); | |
// Set up the headers required for this request. | |
final Map<String, String> headers = <String,String>{}; | |
headers.addAll(await _authHeaders); | |
headers['Content-type'] = 'application/octet-stream'; | |
headers['X-Goog-Upload-Protocol'] = 'raw'; | |
headers['X-Goog-Upload-File-Name'] = filename; | |
// Make the HTTP request to upload the image. The file is sent in the body. |
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
Future<BatchCreateMediaItemsResponse> createMediaItem( | |
String uploadToken, String albumId, String description) { | |
// Construct the request with the token, albumId and description. | |
final BatchCreateMediaItemsRequest request = | |
BatchCreateMediaItemsRequest.inAlbum(uploadToken, albumId, description); | |
// Make the API call to create the media item. The response contains a | |
// media item. | |
return client | |
.batchCreateMediaItems(request) |
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
Future<void> _shareAlbum(BuildContext context) async { | |
// Show the loading indicator | |
setState(() { | |
_inSharingApiCall = true; | |
}); | |
final SnackBar snackBar = SnackBar( | |
duration: Duration(seconds: 3), | |
content: const Text('Sharing Album...'), | |
); | |
Scaffold.of(context).showSnackBar(snackBar); |
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
void _showShareableUrl(BuildContext context) { | |
if (album.shareInfo == null || album.shareInfo.shareableUrl == null) { | |
print('Not shared, sharing album first.'); | |
// Album is not shared yet, share it first, then display dialog | |
_shareAlbum(context).then((_) { | |
_showUrlDialog(context); | |
}); | |
} else { | |
// Album is already shared, display dialog with URL | |
_showUrlDialog(context); |