-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from nimblehq/release/0.3.0
[Release] 0.3.0
- Loading branch information
Showing
51 changed files
with
1,439 additions
and
72 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import 'package:japx/japx.dart'; | ||
|
||
class ResponseDecoder { | ||
static Map<String, dynamic> decode(Map<String, dynamic> json) { | ||
static Map<String, dynamic> decodeData(Map<String, dynamic> json) { | ||
return Japx.decode(json)['data']; | ||
} | ||
|
||
static Map<String, dynamic> decode(Map<String, dynamic> json) => | ||
Japx.decode(json); | ||
} |
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,16 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:retrofit/http.dart'; | ||
import 'package:survey_flutter/model/response/surveys_container_response.dart'; | ||
|
||
part 'survey_api_service.g.dart'; | ||
|
||
@RestApi() | ||
abstract class SurveyApiService { | ||
factory SurveyApiService(Dio dio, {String baseUrl}) = _SurveyApiService; | ||
|
||
@GET('/surveys') | ||
Future<SurveysContainerResponse> getSurveys( | ||
@Query('page[number]') int pageNumber, | ||
@Query('page[size]') int pageSize, | ||
); | ||
} |
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,18 @@ | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
|
||
class FlutterSecureStorageProvider { | ||
FlutterSecureStorage? _storage; | ||
|
||
FlutterSecureStorage getStorage() { | ||
_storage ??= _createStorage(); | ||
return _storage!; | ||
} | ||
|
||
FlutterSecureStorage _createStorage() { | ||
return const FlutterSecureStorage( | ||
aOptions: AndroidOptions( | ||
encryptedSharedPreferences: 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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
{ | ||
"okText": "OK", | ||
"emailInputHint": "Email", | ||
"passwordInputHint": "Password", | ||
"loginButton": "Log in", | ||
"invalidEmailError": "Please enter the valid email format.", | ||
"invalidPasswordError": "Password must be at least 8 characters long." | ||
"invalidPasswordError": "Password must be at least 8 characters long.", | ||
"unauthorizedError": "Your email or password is incorrect.\nPlease try again.", | ||
"noInternetConnectionError": "You seem to be offline.\nPlease try again!", | ||
"genericError": "Something went wrong.\nPlease try again!", | ||
"loginFailAlertTitle": "Unable to log in", | ||
"today": "Today" | ||
} |
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,35 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:survey_flutter/storage/secure_storage.dart'; | ||
|
||
part 'api_token.g.dart'; | ||
|
||
@JsonSerializable() | ||
class ApiToken extends SecureStorageModel { | ||
@JsonKey(name: 'access_token') | ||
final String accessToken; | ||
@JsonKey(name: 'refresh_token') | ||
final String refreshToken; | ||
@JsonKey(name: 'token_type') | ||
final String tokenType; | ||
|
||
ApiToken({ | ||
required this.accessToken, | ||
required this.refreshToken, | ||
required this.tokenType, | ||
}); | ||
|
||
factory ApiToken.fromJson(Map<String, dynamic> json) => | ||
_$ApiTokenFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$ApiTokenToJson(this); | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
other is ApiToken && | ||
accessToken == other.accessToken && | ||
refreshToken == other.refreshToken && | ||
tokenType == other.tokenType; | ||
|
||
@override | ||
int get hashCode => (accessToken + refreshToken + tokenType).hashCode; | ||
} |
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,31 @@ | ||
import 'package:equatable/equatable.dart'; | ||
|
||
class MetaModel extends Equatable { | ||
final int page; | ||
final int pages; | ||
final int pageSize; | ||
final int records; | ||
|
||
const MetaModel({ | ||
required this.page, | ||
required this.pages, | ||
required this.pageSize, | ||
required this.records, | ||
}); | ||
|
||
const MetaModel.dummy() | ||
: this( | ||
page: 0, | ||
pages: 0, | ||
pageSize: 0, | ||
records: 0, | ||
); | ||
|
||
@override | ||
List<Object?> get props => [ | ||
page, | ||
pages, | ||
pageSize, | ||
records, | ||
]; | ||
} |
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,39 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:survey_flutter/api/response_decoder.dart'; | ||
import 'package:survey_flutter/model/meta_model.dart'; | ||
|
||
part 'meta_response.g.dart'; | ||
|
||
@JsonSerializable() | ||
class MetaResponse { | ||
final int? page; | ||
final int? pages; | ||
final int? pageSize; | ||
final int? records; | ||
|
||
MetaResponse({ | ||
required this.page, | ||
required this.pages, | ||
required this.pageSize, | ||
required this.records, | ||
}); | ||
|
||
factory MetaResponse.fromJson(Map<String, dynamic> json) => | ||
_$MetaResponseFromJson(ResponseDecoder.decode(json)); | ||
|
||
static MetaResponse dummy() { | ||
return MetaResponse( | ||
page: 0, | ||
pages: 0, | ||
pageSize: 0, | ||
records: 0, | ||
); | ||
} | ||
|
||
MetaModel toMetaModel() => MetaModel( | ||
page: page ?? 0, | ||
pages: pages ?? 0, | ||
pageSize: pageSize ?? 0, | ||
records: records ?? 0, | ||
); | ||
} |
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,31 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:survey_flutter/api/response_decoder.dart'; | ||
import 'package:survey_flutter/model/survey_model.dart'; | ||
|
||
part 'survey_response.g.dart'; | ||
|
||
@JsonSerializable() | ||
class SurveyResponse { | ||
final String? id; | ||
final String? title; | ||
final String? description; | ||
final String? coverImageUrl; | ||
|
||
SurveyResponse({ | ||
required this.id, | ||
required this.title, | ||
required this.description, | ||
required this.coverImageUrl, | ||
}); | ||
|
||
factory SurveyResponse.fromJson(Map<String, dynamic> json) => | ||
_$SurveyResponseFromJson(ResponseDecoder.decodeData(json)); | ||
|
||
SurveyModel toSurveyModel() => SurveyModel( | ||
id: id ?? '', | ||
title: title ?? '', | ||
description: description ?? '', | ||
coverImageUrl: coverImageUrl ?? '', | ||
); | ||
} |
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,29 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:survey_flutter/api/response_decoder.dart'; | ||
import 'package:survey_flutter/model/meta_model.dart'; | ||
import 'package:survey_flutter/model/response/meta_response.dart'; | ||
import 'package:survey_flutter/model/response/survey_response.dart'; | ||
import 'package:survey_flutter/model/surveys_container_model.dart'; | ||
|
||
part 'surveys_container_response.g.dart'; | ||
|
||
@JsonSerializable() | ||
class SurveysContainerResponse { | ||
final List<SurveyResponse>? data; | ||
final MetaResponse? meta; | ||
|
||
const SurveysContainerResponse({ | ||
required this.data, | ||
required this.meta, | ||
}); | ||
|
||
factory SurveysContainerResponse.fromJson(Map<String, dynamic> json) { | ||
return _$SurveysContainerResponseFromJson(ResponseDecoder.decode(json)); | ||
} | ||
|
||
SurveysContainerModel toSurveysContainerModel() => SurveysContainerModel( | ||
surveys: | ||
data?.map((item) => item.toSurveyModel()).toList() ?? List.empty(), | ||
meta: meta?.toMetaModel() ?? const MetaModel.dummy(), | ||
); | ||
} |
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,23 @@ | ||
import 'package:equatable/equatable.dart'; | ||
|
||
class SurveyModel extends Equatable { | ||
final String id; | ||
final String title; | ||
final String description; | ||
final String coverImageUrl; | ||
|
||
const SurveyModel({ | ||
required this.id, | ||
required this.title, | ||
required this.description, | ||
required this.coverImageUrl, | ||
}); | ||
|
||
@override | ||
List<Object?> get props => [ | ||
id, | ||
title, | ||
description, | ||
coverImageUrl, | ||
]; | ||
} |
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,25 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:survey_flutter/model/meta_model.dart'; | ||
import 'package:survey_flutter/model/survey_model.dart'; | ||
|
||
class SurveysContainerModel extends Equatable { | ||
final List<SurveyModel> surveys; | ||
final MetaModel meta; | ||
|
||
const SurveysContainerModel({ | ||
required this.surveys, | ||
required this.meta, | ||
}); | ||
|
||
SurveysContainerModel.dummy() | ||
: this( | ||
surveys: List.empty(), | ||
meta: const MetaModel.dummy(), | ||
); | ||
|
||
@override | ||
List<Object?> get props => [ | ||
surveys, | ||
meta, | ||
]; | ||
} |
Oops, something went wrong.