Skip to content

Commit

Permalink
Merge pull request #52 from nimblehq/release/0.2.0
Browse files Browse the repository at this point in the history
[Release] 0.2.0
  • Loading branch information
nkhanh44 authored Aug 11, 2023
2 parents 7626211 + 32f7d09 commit 3382c2e
Show file tree
Hide file tree
Showing 42 changed files with 869 additions and 209 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SECRET=
REST_API_ENDPOINT=
CLIENT_ID=
CLIENT_SECRET=
Binary file added assets/images/2.0x/splash_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2.0x/splash_logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3.0x/splash_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3.0x/splash_logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/nimble_logo.png
Binary file not shown.
Binary file added assets/images/splash_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/splash_logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 0 additions & 20 deletions integration_test/my_home_page_test.dart

This file was deleted.

2 changes: 1 addition & 1 deletion integration_test/utils/test_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestUtil {
/// localization, routes, etc)
static Widget pumpWidgetWithRealApp(String initialRoute) {
_initDependencies();
return MyApp();
return App();
}

/// We normally use this function to test a specific [widget] without
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 632d6ac0b577d6e268ff7a13a105bbc4f7941989

COCOAPODS: 1.12.0
COCOAPODS: 1.12.1
14 changes: 0 additions & 14 deletions lib/api/api_service.dart

This file was deleted.

17 changes: 17 additions & 0 deletions lib/api/authentication_api_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:dio/dio.dart';
import 'package:survey_flutter/model/request/login_request.dart';
import 'package:survey_flutter/model/response/login_response.dart';
import 'package:retrofit/retrofit.dart';

part 'authentication_api_service.g.dart';

@RestApi()
abstract class AuthenticationApiService {
factory AuthenticationApiService(Dio dio, {String baseUrl}) =
_AuthenticationApiService;

@POST('/oauth/token')
Future<LoginResponse> login(
@Body() LoginRequest body,
);
}
22 changes: 0 additions & 22 deletions lib/api/repository/credential_repository.dart

This file was deleted.

7 changes: 7 additions & 0 deletions lib/api/response_decoder.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:japx/japx.dart';

class ResponseDecoder {
static Map<String, dynamic> decode(Map<String, dynamic> json) {
return Japx.decode(json)['data'];
}
}
8 changes: 8 additions & 0 deletions lib/env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ class Env {
static String get restApiEndpoint {
return FlutterConfig.get('REST_API_ENDPOINT');
}

static String get clientId {
return FlutterConfig.get('CLIENT_ID');
}

static String get clientSecret {
return FlutterConfig.get('CLIENT_SECRET');
}
}
6 changes: 5 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"hello": "Hello!"
"emailInputHint": "Email",
"passwordInputHint": "Password",
"loginButton": "Log in",
"invalidEmailError": "Please enter the valid email format.",
"invalidPasswordError": "Password must be at least 8 characters long."
}
3 changes: 0 additions & 3 deletions lib/l10n/app_th.arb

This file was deleted.

3 changes: 0 additions & 3 deletions lib/l10n/app_vi.arb

This file was deleted.

102 changes: 21 additions & 81 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
import 'package:flutter/material.dart';
import 'package:flutter_config/flutter_config.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:survey_flutter/gen/assets.gen.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:survey_flutter/screens/login/login_screen.dart';
import 'package:survey_flutter/screens/splash/splash_screen.dart';
import 'package:survey_flutter/theme/app_theme.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterConfig.loadEnvVariables();
runApp(MyApp());
runApp(
ProviderScope(
child: App(),
),
);
}

const routePathRootScreen = '/';
const routePathSecondScreen = 'second';
const routePathSplashScreen = '/';

class MyApp extends StatelessWidget {
MyApp({Key? key}) : super(key: key);
class App extends StatelessWidget {
App({Key? key}) : super(key: key);

final GoRouter _router = GoRouter(
routes: <GoRoute>[
GoRoute(
path: routePathRootScreen,
builder: (BuildContext context, GoRouterState state) =>
const HomeScreen(),
routes: [
GoRoute(
path: routePathSecondScreen,
builder: (BuildContext context, GoRouterState state) =>
const SecondScreen(),
),
],
path: routePathSplashScreen,
builder: (_, __) => const SplashScreen(),
),
GoRoute(
path: routePathLoginScreen,
pageBuilder: (_, __) => const NoTransitionPage<void>(
child: LoginScreen(),
),
),
],
);

@override
Widget build(BuildContext context) {
return MaterialApp.router(
theme: ThemeData(
primarySwatch: Colors.blue,
brightness: Brightness.light,
fontFamily: Assets.fonts.neuzeit,
),
theme: AppTheme.light,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
routeInformationProvider: _router.routeInformationProvider,
Expand All @@ -50,62 +49,3 @@ class MyApp extends StatelessWidget {
);
}
}

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

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
return snapshot.hasData
? Text(snapshot.data?.appName ?? "")
: const SizedBox.shrink();
}),
),
body: Center(
child: Column(
children: [
const SizedBox(height: 24),
FractionallySizedBox(
widthFactor: 0.5,
child: Image.asset(
Assets.images.nimbleLogo.path,
fit: BoxFit.fitWidth,
),
),
const SizedBox(height: 24),
Text(AppLocalizations.of(context)!.hello),
Text(
FlutterConfig.get('SECRET'),
style: const TextStyle(color: Colors.black, fontSize: 24),
),
const SizedBox(height: 24),
ElevatedButton(
onPressed: () => context.go('/$routePathSecondScreen'),
child: const Text("Navigate to Second Screen"),
),
],
),
),
);
}
}

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

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Second Screen"),
),
);
}
}
23 changes: 23 additions & 0 deletions lib/model/login_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:equatable/equatable.dart';

class LoginModel extends Equatable {
final String id;
final String accessToken;
final double expiresIn;
final String refreshToken;

const LoginModel({
required this.id,
required this.accessToken,
required this.expiresIn,
required this.refreshToken,
});

@override
List<Object?> get props => [
id,
accessToken,
expiresIn,
refreshToken,
];
}
22 changes: 22 additions & 0 deletions lib/model/request/login_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:json_annotation/json_annotation.dart';

part 'login_request.g.dart';

@JsonSerializable()
class LoginRequest {
final String grantType;
final String email;
final String password;
final String clientId;
final String clientSecret;

LoginRequest({
required this.grantType,
required this.email,
required this.password,
required this.clientId,
required this.clientSecret,
});

Map<String, dynamic> toJson() => _$LoginRequestToJson(this);
}
45 changes: 45 additions & 0 deletions lib/model/response/login_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:survey_flutter/api/response_decoder.dart';
import 'package:survey_flutter/model/login_model.dart';

part 'login_response.g.dart';

@JsonSerializable()
class LoginResponse {
final String id;
final String accessToken;
final String tokenType;
final double expiresIn;
final String refreshToken;
final int createdAt;

LoginResponse({
required this.id,
required this.accessToken,
required this.tokenType,
required this.expiresIn,
required this.refreshToken,
required this.createdAt,
});

factory LoginResponse.fromJson(Map<String, dynamic> json) =>
_$LoginResponseFromJson(ResponseDecoder.decode(json));

LoginModel toLoginModel() => LoginModel(
id: id,
accessToken: accessToken,
expiresIn: expiresIn,
refreshToken: refreshToken,
);

static LoginResponse dummy() {
return LoginResponse(
id: "",
accessToken: "",
tokenType: "",
expiresIn: 0,
refreshToken: "",
createdAt: 0,
);
}
}
16 changes: 0 additions & 16 deletions lib/model/response/user_response.dart

This file was deleted.

Loading

0 comments on commit 3382c2e

Please sign in to comment.