Skip to content

Commit

Permalink
Merge pull request #3 from Nuxify/feature/upgrade-flutter
Browse files Browse the repository at this point in the history
feat: upgrade to flutter 2
  • Loading branch information
kabaluyot authored May 1, 2021
2 parents 16bcfd5 + 655836b commit 476b357
Show file tree
Hide file tree
Showing 22 changed files with 249 additions and 253 deletions.
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PODS:
- MTBBarcodeScanner (5.0.11)
- path_provider (0.0.1):
- Flutter
- qr_code_scanner (0.0.2):
- qr_code_scanner (0.2.0):
- Flutter
- MTBBarcodeScanner

Expand All @@ -31,10 +31,10 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
camera: a0ca5080336f7af47b88436e5e26da3dee5568f0
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
qr_code_scanner: 16107718bdad7d708cdf6a5eacdca24b56cdf471
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e

PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions lib/infrastructures/api/api_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ part 'api_response.g.dart';
genericArgumentFactories: true,
)
class APIResponse<T> {
APIResponse({this.success, this.message, this.errorCode, this.data});
APIResponse({
required this.success,
required this.message,
required this.errorCode,
required this.data,
});

factory APIResponse.fromJson(
Map<String, dynamic> json,
T Function(Object json) fromJsonT,
T Function(Object? json) fromJsonT,
) =>
_$APIResponseFromJson(json, fromJsonT);
Map<String, dynamic> toJson(Object Function(T value) toJsonT) =>
Expand All @@ -27,21 +32,24 @@ class APIResponse<T> {
/// base API response
final bool success;
final String message;
@JsonKey(nullable: true)
final String errorCode;
@JsonKey(nullable: true)
final String? errorCode;
final T data;
}

@JsonSerializable(
genericArgumentFactories: true,
)
class APIListResponse<T> {
APIListResponse({this.success, this.message, this.errorCode, this.data});
APIListResponse({
required this.success,
required this.message,
required this.errorCode,
required this.data,
});

factory APIListResponse.fromJson(
Map<String, dynamic> json,
T Function(Object json) fromJsonT,
T Function(Object? json) fromJsonT,
) =>
_$APIListResponseFromJson(json, fromJsonT);
Map<String, dynamic> toJson(Object Function(T value) toJsonT) =>
Expand All @@ -50,8 +58,6 @@ class APIListResponse<T> {
/// base API response
final bool success;
final String message;
@JsonKey(nullable: true)
final String errorCode;
@JsonKey(nullable: true)
final String? errorCode;
final List<T> data;
}
5 changes: 1 addition & 4 deletions lib/interfaces/widgets/header.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import 'package:flutter/material.dart';

class Header extends StatelessWidget with PreferredSizeWidget {
const Header({
Key key,
this.title,
}) : super(key: key);
const Header({required this.title, Key? key}) : super(key: key);

final String title;

Expand Down
32 changes: 19 additions & 13 deletions lib/interfaces/widgets/rounded_button.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:flutter/material.dart';

class RoundedButton extends StatelessWidget {
const RoundedButton({
@required this.buttonLabel,
@required this.buttonIcon,
@required this.onPressedFunc,
Key key,
}) : super(key: key);
const RoundedButton(
{required this.buttonLabel,
required this.buttonIcon,
required this.onPressedFunc,
Key? key})
: super(key: key);

final String buttonLabel;
final IconData buttonIcon;
Expand All @@ -29,7 +29,7 @@ class RoundedButton extends StatelessWidget {
),
borderRadius: BorderRadius.circular(5.0),
),
child: FlatButton.icon(
child: TextButton.icon(
onPressed: () {
onPressedFunc();
},
Expand All @@ -42,12 +42,18 @@ class RoundedButton extends StatelessWidget {
buttonIcon,
color: Colors.white,
),
padding: const EdgeInsets.symmetric(
vertical: 15,
),
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
style: ButtonStyle(
padding: MaterialStateProperty.all(
const EdgeInsets.symmetric(
vertical: 15,
),
),
backgroundColor: MaterialStateProperty.all(Colors.transparent),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
),
),
),
),
Expand Down
10 changes: 5 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'package:Flirt/configs/themes.dart';
import 'package:Flirt/routes.dart';
import 'package:Flirt/module/record/service/cubit/record_cubit.dart';
import 'package:Flirt/module/home/interfaces/screens/home_screen.dart';
import 'package:flirt/configs/themes.dart';
import 'package:flirt/routes.dart';
import 'package:flirt/module/record/service/cubit/record_cubit.dart';
import 'package:flirt/module/home/interfaces/screens/home_screen.dart';

void main() => runApp(const App());

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

@override
Widget build(BuildContext context) {
Expand Down
10 changes: 4 additions & 6 deletions lib/module/home/interfaces/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'package:flutter/material.dart';

import 'package:Flirt/module/home/interfaces/widgets/bottom_bubble.dart';
import 'package:Flirt/module/home/interfaces/widgets/main_button_bar.dart';
import 'package:Flirt/module/home/interfaces/widgets/top_bubble.dart';
import 'package:flirt/module/home/interfaces/widgets/bottom_bubble.dart';
import 'package:flirt/module/home/interfaces/widgets/main_button_bar.dart';
import 'package:flirt/module/home/interfaces/widgets/top_bubble.dart';

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

static const String routeName = '/home';

Expand Down
4 changes: 1 addition & 3 deletions lib/module/home/interfaces/widgets/bottom_bubble.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
Expand Down
10 changes: 4 additions & 6 deletions lib/module/home/interfaces/widgets/main_button_bar.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'package:flutter/material.dart';

import 'package:Flirt/module/record/interfaces/screens/generate/generate_screen.dart';
import 'package:Flirt/module/record/interfaces/screens/scan/scan_screen.dart';
import 'package:Flirt/interfaces/widgets/rounded_button.dart';
import 'package:flirt/module/record/interfaces/screens/generate/generate_screen.dart';
import 'package:flirt/module/record/interfaces/screens/scan/scan_screen.dart';
import 'package:flirt/interfaces/widgets/rounded_button.dart';

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

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 1 addition & 3 deletions lib/module/home/interfaces/widgets/top_bubble.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
Expand Down
34 changes: 20 additions & 14 deletions lib/module/record/interfaces/screens/generate/generate_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:qr_flutter/qr_flutter.dart';

import 'package:Flirt/interfaces/widgets/header.dart';
import 'package:Flirt/module/record/service/cubit/record_dto.dart';
import 'package:Flirt/module/record/service/cubit/record_cubit.dart';
import 'package:flirt/interfaces/widgets/header.dart';
import 'package:flirt/module/record/service/cubit/record_dto.dart';
import 'package:flirt/module/record/service/cubit/record_cubit.dart';

class GenerateScreen extends StatefulWidget {
const GenerateScreen({
Key key,
Key? key,
}) : super(key: key);

static const String routeName = '/generate';
Expand Down Expand Up @@ -45,7 +45,7 @@ class _GenerateScreenState extends State<GenerateScreen> {
data: _dataTextController.text,
);
context.read<RecordCubit>().recordData(payload);
Scaffold.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).hideCurrentSnackBar();
}

@override
Expand Down Expand Up @@ -89,7 +89,7 @@ class _GenerateScreenState extends State<GenerateScreen> {
RecordState state,
) {
if (state is RecordFailed) {
Scaffold.of(context).showSnackBar(
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: _theme.errorColor,
content: Text('Error: ${state.message}'),
Expand All @@ -100,7 +100,7 @@ class _GenerateScreenState extends State<GenerateScreen> {
setState(() {
_generatedQRCode = state.recordResponse.id;
});
Scaffold.of(context).showSnackBar(
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 120),
backgroundColor: Colors.green,
Expand All @@ -124,21 +124,27 @@ class _GenerateScreenState extends State<GenerateScreen> {
final String buttonText = (state is RecordLoading)
? 'GENERATING...'
: 'GENERATE';
return FlatButton.icon(
textColor: Colors.white,
return TextButton.icon(
style: ButtonStyle(
padding: MaterialStateProperty.all(
const EdgeInsets.symmetric(
vertical: 20,
),
),
backgroundColor:
MaterialStateProperty.all(_theme.primaryColor),
),
icon: const Icon(
Icons.select_all,
),
label: Text(buttonText,
style: const TextStyle(fontSize: 20.0)),
padding: const EdgeInsets.symmetric(
vertical: 20,
label: Text(
buttonText,
style: const TextStyle(fontSize: 20.0),
),
onPressed:
(state is RecordLoading || state is RecordSuccess)
? null
: () => _generateQRCode(context),
color: _theme.primaryColor,
);
},
),
Expand Down
20 changes: 10 additions & 10 deletions lib/module/record/interfaces/screens/result/result_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:qr_flutter/qr_flutter.dart';

import 'package:Flirt/interfaces/widgets/header.dart';
import 'package:Flirt/module/record/service/cubit/record_cubit.dart';
import 'package:Flirt/interfaces/widgets/rounded_button.dart';
import 'package:Flirt/module/record/interfaces/screens/scan/scan_screen.dart';
import 'package:flirt/interfaces/widgets/header.dart';
import 'package:flirt/module/record/service/cubit/record_cubit.dart';
import 'package:flirt/interfaces/widgets/rounded_button.dart';
import 'package:flirt/module/record/interfaces/screens/scan/scan_screen.dart';

class ResultScreen extends StatefulWidget {
const ResultScreen({
Key key,
Key? key,
this.qrData,
this.rescan,
}) : super(key: key);

static const String routeName = '/result';

final String qrData;
final Function rescan;
final String? qrData;
final Function? rescan;

@override
_ResultScreenState createState() => _ResultScreenState();
Expand All @@ -26,7 +26,7 @@ class ResultScreen extends StatefulWidget {
class _ResultScreenState extends State<ResultScreen> {
@override
void initState() {
context.read<RecordCubit>().fetchRecord(widget.qrData);
context.read<RecordCubit>().fetchRecord(widget.qrData!);
super.initState();
}

Expand All @@ -36,7 +36,7 @@ class _ResultScreenState extends State<ResultScreen> {
final ThemeData _theme = Theme.of(context);
return WillPopScope(
onWillPop: () async {
widget.rescan();
widget.rescan!();
return true;
},
child: Scaffold(
Expand Down Expand Up @@ -136,7 +136,7 @@ class _ResultScreenState extends State<ResultScreen> {
context,
ScanScreen.routeName,
);
widget.rescan();
widget.rescan!();
},
)
],
Expand Down
Loading

0 comments on commit 476b357

Please sign in to comment.