Skip to content

Commit

Permalink
Merge pull request #84 from fanzru/staging
Browse files Browse the repository at this point in the history
Bump Main
  • Loading branch information
kaenova authored Jun 16, 2022
2 parents bbb11b1 + bf8c353 commit d0369fa
Show file tree
Hide file tree
Showing 30 changed files with 1,064 additions and 742 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/BuildAPKDebug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: Build Mobile Debug Staging

on:
push:
branches:
# Only run when there's a push / commits on main branch
- "staging"
paths:
- "mobile/**"
tags:
# Can be built anywhere with tags "internal-v*"
- "internal-v*"

jobs:
BuildDebug:
Expand All @@ -23,9 +21,9 @@ jobs:
with:
timezoneLinux: "Asia/Jakarta"

- name: Create Tags
- name: Get Tags
id: tags
run: echo "::set-output name=sha_short::${GITHUB_SHA::7}"
run: echo "::set-output name=tag::${GITHUB_REF#refs/*/}"

- name: Get Current Date
id: date
Expand Down Expand Up @@ -61,9 +59,8 @@ jobs:
- name: "Create Release"
uses: ncipollo/release-action@v1
with:
name: "Debug Auto Build - ${{ steps.date.outputs.date }}"
tag: ${{ steps.tags.outputs.sha_short }}
commit: "main"
name: "Debug Auto Build - ${{ steps.tags.outputs.tag }} - ${{ steps.date.outputs.date }}"
artifacts: "mobile/artifacts/*.apk"
body: "An auto build on staging at ${{ steps.date.outputs.date }}"
allowUpdates: "true"
body: "An auto build for internal at ${{ steps.date.outputs.date }} for ${{ steps.tags.outputs.tag }}"
token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 10 additions & 10 deletions .github/workflows/BuildAPKRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ name: Build Mobile Release
on:
push:
branches:
# Only run when there's a push / commits on main branch
# Only can be built on Main
- "main"
paths:
- "mobile/**"
tags:
# With a tags "v*"
- "v*"

jobs:
BuildRelease:
Expand All @@ -23,9 +24,9 @@ jobs:
with:
timezoneLinux: "Asia/Jakarta"

- name: Create Tags
- name: Get Tags
id: tags
run: echo "::set-output name=sha_short::${GITHUB_SHA::7}"
run: echo "::set-output name=tag::${GITHUB_REF#refs/*/}"

- name: Get Current Date
id: date
Expand Down Expand Up @@ -61,9 +62,8 @@ jobs:
- name: "Create Release"
uses: ncipollo/release-action@v1
with:
name: "Release Auto Build - ${{ steps.date.outputs.date }}"
tag: ${{ steps.tags.outputs.sha_short }}
commit: "main"
name: "Release Auto Build - ${{ steps.tags.outputs.tag }} - ${{ steps.date.outputs.date }}"
artifacts: "mobile/artifacts/*.apk"
body: "An auto build on main at ${{ steps.date.outputs.date }}"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: "true"
body: "An auto build for release at ${{ steps.date.outputs.date }} for ${{ steps.tags.outputs.tag }}"
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion mobile/lib/api/review.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Future<void> createReview(
if (e.response != null) {
var response = e.response!;
if (response.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired");
}
if (response.statusCode == 400) {
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/api/tikum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Future<List<TikumProfile>> getMyTikum() async {
);

if (response.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired");
}

Expand Down Expand Up @@ -64,7 +64,7 @@ Future<void> deleteMyTikum(int id) async {
);

if (response.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired");
}

Expand Down Expand Up @@ -106,7 +106,7 @@ Future<void> createTikum({
if (e.response != null) {
var response = e.response!;
if (response.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired");
}
if (response.statusCode == 400) {
Expand Down
12 changes: 6 additions & 6 deletions mobile/lib/api/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Future<void> loginUser(String email, String password) async {
var id = decoded["user"]["id"];

var profile = await SecureProfile.getStorage();
profile.setLoggedIn(id, token);
await profile.setLoggedIn(id, token);
} else if (response.statusCode == 400) {
return Future.error("Email atau password salah");
} else {
Expand Down Expand Up @@ -59,7 +59,7 @@ Future<List<ReviewProfile>> getMyReviewById() async {
);

if (response.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired, please login again");
}

Expand Down Expand Up @@ -88,7 +88,7 @@ Future<Profile> getMyProfileById() async {
);

if (response.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired, please login again");
}

Expand Down Expand Up @@ -118,7 +118,7 @@ Future<void> deleteMyReview(int id) async {
);

if (response.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired, please login again");
}

Expand All @@ -144,15 +144,15 @@ Future<void> userLogout() async {
);

if (res.statusCode == 401) {
profile.setLoggedOut();
await profile.setLoggedOut();
return Future.error("Session expired, please login again");
}

if (res.statusCode != 200) {
return Future.error("Failed to logout");
}

profile.setLoggedOut();
await profile.setLoggedOut();
}

Future<Profile> getUserProfileById(int id) async {
Expand Down
8 changes: 4 additions & 4 deletions mobile/lib/model/profile.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "./user.dart";
import "./review.dart";

class Profile {
final dynamic avgRating, totalReview;
final double avgRating;
final int totalReview;
// final List<ReviewProfile> reviews;
final User user;

Expand All @@ -23,8 +23,8 @@ class Profile {
return Profile(
user: user,
// reviews: json["reviews"],
totalReview: json["total_review"],
avgRating: json["avg_ratings"],
totalReview: json["total_review"].toInt(),
avgRating: json["avg_ratings"].toDouble(),
);
}
}
4 changes: 2 additions & 2 deletions mobile/lib/model/profile_secure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ class SecureProfile {
return userId;
}

void setLoggedIn(int userId, String apiKey) async {
Future<void> setLoggedIn(int userId, String apiKey) async {
await storage.setInt("user_id", userId);
await storage.setString("api_key", apiKey);
isLoggedIn = true;
}

void setLoggedOut() async {
Future<void> setLoggedOut() async {
await storage.remove("api_key");
await storage.remove("user_id");
isLoggedIn = false;
Expand Down
23 changes: 23 additions & 0 deletions mobile/lib/screen/_global/components/image_network.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:mobile/screen/_global/components/shimmer/shimmer_container.dart';

class ImageNetworkWShimmer extends StatelessWidget {
final String link;
double? width, height;
BoxFit? fit;
ImageNetworkWShimmer(
{Key? key, required this.link, this.width, this.height, this.fit})
: super(key: key);

@override
Widget build(BuildContext context) {
return Image.network(link, fit: fit, width: width, height: height,
loadingBuilder: (context, child, ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return ShimmerContainer(
width: width,
height: height ?? 300,
);
});
}
}
80 changes: 80 additions & 0 deletions mobile/lib/screen/_global/components/profile_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import 'package:flutter/material.dart';
import 'package:mobile/model/profile.dart';
import "dart:math" as math;

import 'package:mobile/screen/_global/components/image_network.dart';

class ProfileCard extends StatelessWidget {
final Profile data;
// final GlobalKey<NavigatorState> navKey;
final int randomForProfile = math.Random().nextInt(1000);

ProfileCard({Key? key, required this.data}) : super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
margin: const EdgeInsets.symmetric(vertical: 30),
height: 100,
width: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: ImageNetworkWShimmer(
link:
"https://www.thiswaifudoesnotexist.net/example-$randomForProfile.jpg",
fit: BoxFit.cover,
),
),
),
Text(
data.user.name.toString(),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
Container(
margin: const EdgeInsets.symmetric(
vertical: 20,
horizontal: 15,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 20,
),
child: Column(
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text("Total Review"),
Text(data.totalReview.toString()),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 20,
),
child: Column(
// ignore: prefer_const_literals_to_create_immutables
children: [
const Text("Rataan Rating"),
Text(data.avgRating.toStringAsFixed(2)),
],
),
),
],
),
),
]),
);
}
}
70 changes: 70 additions & 0 deletions mobile/lib/screen/_global/components/shimmer/profile_shimmer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:mobile/screen/_global/components/shimmer/shimmer_container.dart';

class ShimmerProfile extends StatelessWidget {
const ShimmerProfile({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(
margin: const EdgeInsets.symmetric(vertical: 30),
height: 100,
width: 100,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: const ShimmerContainer(
width: 50,
height: 50,
)),
),
ShimmerContainer(
width: MediaQuery.of(context).size.width * .4,
),
Container(
margin: const EdgeInsets.symmetric(
vertical: 20,
horizontal: 15,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 20,
),
child: Column(
// ignore: prefer_const_literals_to_create_immutables
children: [
const ShimmerContainer(width: 50),
const SizedBox(height: 5),
ShimmerContainer(
width: MediaQuery.of(context).size.width * .3)
],
),
),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 20,
),
child: Column(
// ignore: prefer_const_literals_to_create_immutables
children: [
const ShimmerContainer(width: 50),
const SizedBox(height: 5),
ShimmerContainer(
width: MediaQuery.of(context).size.width * .3)
],
),
),
],
),
),
]),
);
}
}
Loading

0 comments on commit d0369fa

Please sign in to comment.