Skip to content

Commit

Permalink
WIP - improve example app
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-quiltt committed Oct 3, 2023
1 parent 3ff39e7 commit a4a2e1d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 20 deletions.
30 changes: 30 additions & 0 deletions example/lib/components/bottom_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'constants.dart';

class BottomButton extends StatelessWidget {
const BottomButton(
{super.key, required this.onTap, required this.buttonTitle});

final VoidCallback onTap;
final String buttonTitle;

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
color: kQuilttPurple,
margin: const EdgeInsets.only(top: 10.0),
padding: const EdgeInsets.only(bottom: 20.0),
width: double.infinity,
height: kBottomContainerHeight,
child: Center(
child: Text(
buttonTitle,
style: kLargeButtonTextStyle,
),
),
),
);
}
}
41 changes: 41 additions & 0 deletions example/lib/components/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';

const kBottomContainerHeight = 80.0;
const kActiveCardColour = Color(0xFF1D1E33);
const kInactiveCardColour = Color(0xFF111328);
const kQuilttPurple = Color.fromARGB(255, 98, 2, 142);

const kLabelTextStyle = TextStyle(
fontSize: 18.0,
color: Color(0xFF8D8E98),
);

const kNumberTextStyle = TextStyle(
fontSize: 50.0,
fontWeight: FontWeight.w900,
);

const kLargeButtonTextStyle = TextStyle(
fontSize: 25.0,
fontWeight: FontWeight.bold,
);

const kTitleTextStyle = TextStyle(
fontSize: 50.0,
fontWeight: FontWeight.bold,
);

const kResultTextStyle = TextStyle(
color: Color(0xFF24D876),
fontSize: 22.0,
fontWeight: FontWeight.bold,
);

const kBMITextStyle = TextStyle(
fontSize: 100.0,
fontWeight: FontWeight.bold,
);

const kBodyTextStyle = TextStyle(
fontSize: 22.0,
);
34 changes: 14 additions & 20 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:quiltt_connector/quiltt_connector.dart';
import 'package:quiltt_connector/configuration.dart';
import './components/bottom_button.dart';
import './components/constants.dart';

void main() {
runApp(const MyApp());
Expand Down Expand Up @@ -30,10 +32,10 @@ class MyApp extends StatelessWidget {
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple.shade900),
colorScheme: ColorScheme.fromSeed(seedColor: kQuilttPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Quiltt Connector Home'),
home: const MyHomePage(title: 'Quiltt Connector Example'),
);
}
}
Expand Down Expand Up @@ -66,27 +68,20 @@ class _MyHomePageState extends State<MyHomePage> {
}

_launchConnector() {
String token = "token";

QuilttConnectorConfiguration config = QuilttConnectorConfiguration(
connectorId: "connectorId",
connectorId: "yldluevd9q",
oauthRedirectUrl: "quilttexample://open.flutter.app");

debugPrint(
'_launchConnector: ${config.connectorId}, $config.oauthRedirectUrl');
QuilttConnector quilttConnector = QuilttConnector();
quilttConnector.authenticate(token);
quilttConnector.connect(context, config, onEvent: (event) {
debugPrint("onEvent: ${event.eventMetadata}");
}, onExit: (event) {
debugPrint("onExit: ${event.eventMetadata}");
quilttConnector.connect(context, config, onExit: (event) {
debugPrint("onExit: ${event.type}");
debugPrint("onExit: ${event.eventMetadata.connectorId}");
}, onExitSuccess: (event) {
debugPrint("onExitSuccess: ${event.eventMetadata}");
debugPrint("onExitSuccess: ${event.eventMetadata.connectorId}");
debugPrint("onExitSuccess: ${event.eventMetadata.connectionId}");
_setConnectionId(event.eventMetadata.connectionId!);
}, onExitAbort: (event) {
debugPrint("onExitAbort: ${event.eventMetadata}");
}, onExitError: (event) {
debugPrint("onExitError: ${event.eventMetadata}");
});
}

Expand Down Expand Up @@ -132,13 +127,12 @@ class _MyHomePageState extends State<MyHomePage> {
Text(
'Connection ID: $_connectionId',
),
BottomButton(
onTap: _launchConnector,
buttonTitle: 'Launch Connector',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _launchConnector,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
Expand Down

0 comments on commit a4a2e1d

Please sign in to comment.