mirror of
https://github.com/cupcakearmy/fight-of-the-mobiles.git
synced 2026-04-02 18:25:23 +00:00
code
This commit is contained in:
37
src/flutter/lib/Screens/Home.dart
Normal file
37
src/flutter/lib/Screens/Home.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../Components/BG.dart';
|
||||
import '../Components/Button.dart';
|
||||
import '../Components/ListItem.dart';
|
||||
import '../Components/Logo.dart';
|
||||
|
||||
class Home extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BG(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Padding(padding: EdgeInsets.only(bottom: 80.0), child: Logo()),
|
||||
Button(
|
||||
callback: () {
|
||||
// Navigator.pushNamed(context, '/scan');
|
||||
Navigator.pushNamed(context, '/success/1');
|
||||
},
|
||||
text: "Scan",
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 100.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ListItem(left: 1, right: 'Open Camera.'),
|
||||
ListItem(left: 2, right: 'Scan QR code.'),
|
||||
ListItem(left: 2, right: 'Get notified.'),
|
||||
],
|
||||
))
|
||||
],
|
||||
)));
|
||||
}
|
||||
}
|
||||
39
src/flutter/lib/Screens/Scan.dart
Normal file
39
src/flutter/lib/Screens/Scan.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:barcode_scan/barcode_scan.dart';
|
||||
|
||||
import '../Components/BG.dart';
|
||||
import '../Components/SyncIcon.dart';
|
||||
|
||||
class Scan extends StatelessWidget {
|
||||
Future scan() async {
|
||||
try {
|
||||
String barcode = await BarcodeScanner.scan();
|
||||
print('Success');
|
||||
print(barcode);
|
||||
Navigator.pushNamed(null, '/home');
|
||||
} on PlatformException catch (e) {
|
||||
if (e.code == BarcodeScanner.CameraAccessDenied)
|
||||
print('The user did not grant the camera permission!');
|
||||
} catch (e) {
|
||||
print('Nope');
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => BG(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Scanning...',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
SyncIcon()
|
||||
],
|
||||
)));
|
||||
}
|
||||
54
src/flutter/lib/Screens/Success.dart
Normal file
54
src/flutter/lib/Screens/Success.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
|
||||
import '../Components/BG.dart';
|
||||
import '../Components/Button.dart';
|
||||
|
||||
class Success extends StatelessWidget {
|
||||
final int result;
|
||||
|
||||
Success({@required this.result}) {
|
||||
final initializationSettings = InitializationSettings(
|
||||
AndroidInitializationSettings('app_icon'), IOSInitializationSettings());
|
||||
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin()
|
||||
..initialize(initializationSettings);
|
||||
|
||||
flutterLocalNotificationsPlugin.show(
|
||||
this.result,
|
||||
'🚀 Scan succeded!',
|
||||
'Your super sercret code is: $result',
|
||||
NotificationDetails(
|
||||
AndroidNotificationDetails('your channel id', 'your channel name',
|
||||
'your channel description',
|
||||
importance: Importance.Max, priority: Priority.High),
|
||||
IOSNotificationDetails()),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => BG(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 150.0, bottom: 100.0),
|
||||
child: Button(
|
||||
text: 'Back',
|
||||
callback: () =>
|
||||
Navigator.popUntil(context, ModalRoute.withName('/')),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Success',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10.0),
|
||||
height: 32.0,
|
||||
width: 32.0,
|
||||
child: Image.asset('images/check.png'),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
Reference in New Issue
Block a user