-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy version 2.6.0+23 to alpha for testing (#107)
* Add counter & mini view example (mvc rocket package) (#100) * Add mvc_rocket package * Add counter & mini view example * removed tests * bump version maunually * bump version from 2.2.15+22 to 2.3.0+22 by fastlane plugin * Disabled tests * bump version from 2.3.0+22 to 2.4.0+22 by fastlane plugin * Add posts mvc rocket example (#101) * Add post model * Add post request * Add post view * Integrate posts feature * bump version from 2.4.0+22 to 2.5.0+22 by fastlane plugin * Enhance realse notes (#102) * Add photo mvc rocket example (#105) * Add photo model * Add photo request * Add photo view * Integrate photo screen * format code * bump version from 2.5.0+22 to 2.6.0+22 by fastlane plugin * Fix push bump version on staging (#106)
- Loading branch information
1 parent
bca8bd7
commit 1362d4a
Showing
6 changed files
with
154 additions
and
4 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
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,63 @@ | ||
import 'package:mvc_rocket/mvc_rocket.dart'; | ||
|
||
const String photoAlbumIdField = "albumId"; | ||
const String photoIdField = "id"; | ||
const String photoTitleField = "title"; | ||
const String photoUrlField = "url"; | ||
const String photoThumbnailUrlField = "thumbnailUrl"; | ||
|
||
class Photo extends RocketModel<Photo> { | ||
int? albumId; | ||
int? id; | ||
String? title; | ||
String? url; | ||
String? thumbnailUrl; | ||
|
||
Photo({ | ||
this.albumId, | ||
this.id, | ||
this.title, | ||
this.url, | ||
this.thumbnailUrl, | ||
}); | ||
|
||
@override | ||
void fromJson(Map<String, dynamic> json, {bool isSub = false}) { | ||
albumId = json[photoAlbumIdField]; | ||
id = json[photoIdField]; | ||
title = json[photoTitleField]; | ||
url = json[photoUrlField]; | ||
thumbnailUrl = json[photoThumbnailUrlField]; | ||
super.fromJson(json, isSub: isSub); | ||
} | ||
|
||
void updateFields({ | ||
int? albumIdField, | ||
int? idField, | ||
String? titleField, | ||
String? urlField, | ||
String? thumbnailUrlField, | ||
}) { | ||
albumId = albumIdField ?? albumId; | ||
id = idField ?? id; | ||
title = titleField ?? title; | ||
url = urlField ?? url; | ||
thumbnailUrl = thumbnailUrlField ?? thumbnailUrl; | ||
rebuildWidget(fromUpdate: true); | ||
} | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = {}; | ||
data[photoAlbumIdField] = albumId; | ||
data[photoIdField] = id; | ||
data[photoTitleField] = title; | ||
data[photoUrlField] = url; | ||
data[photoThumbnailUrlField] = thumbnailUrl; | ||
|
||
return data; | ||
} | ||
|
||
@override | ||
get instance => Photo(); | ||
} |
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,9 @@ | ||
import 'package:flutter_ci_cd/models/photo_model.dart'; | ||
import 'package:mvc_rocket/mvc_rocket.dart'; | ||
|
||
const String photosEndpoint = "photos"; | ||
|
||
class GetPhotos { | ||
static Future getPhotos(Photo photoModel) => Rocket.get(rocketRequestKey) | ||
.getObjData(photosEndpoint, photoModel, multi: true); | ||
} |
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,75 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_ci_cd/models/photo_model.dart'; | ||
import 'package:flutter_ci_cd/requests/photo_request.dart'; | ||
import 'package:mvc_rocket/mvc_rocket.dart'; | ||
|
||
class PhotoExample extends StatelessWidget { | ||
PhotoExample({Key? key, required this.title}) : super(key: key); | ||
final String title; | ||
final Photo photo = Rocket.add<Photo>(photosEndpoint, Photo()); | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(title), | ||
), | ||
body: SizedBox( | ||
height: MediaQuery.of(context).size.height, | ||
width: MediaQuery.of(context).size.width, | ||
child: RocketView( | ||
model: photo, | ||
// get 5000 items | ||
call: () => GetPhotos.getPhotos(photo), | ||
builder: (context) { | ||
return ListView.builder( | ||
itemCount: photo.multi!.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
Photo currentphoto = photo.multi![index]; | ||
return Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Column( | ||
children: [ | ||
ListTile( | ||
title: Text(currentphoto.title!), | ||
leading: Text(currentphoto.id!.toString()), | ||
onTap: () { | ||
Navigator.of(context).push(MaterialPageRoute( | ||
builder: (BuildContext context) { | ||
return ApiImage(currentphoto.url!); | ||
})); | ||
}, | ||
), | ||
], | ||
), | ||
); | ||
}); | ||
}, | ||
)), | ||
); | ||
} | ||
} | ||
|
||
class ApiImage extends StatelessWidget { | ||
final String url; | ||
const ApiImage(this.url, {Key? key}) : super(key: key); | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: Center( | ||
child: Image.network( | ||
url, | ||
frameBuilder: (_, child, __, ___) { | ||
return Container( | ||
decoration: BoxDecoration(boxShadow: [ | ||
BoxShadow( | ||
blurRadius: 10.0, | ||
color: Colors.black.withAlpha(100), | ||
offset: Offset.zero) | ||
]), | ||
child: child, | ||
); | ||
}, | ||
)), | ||
); | ||
} | ||
} |
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