From a4a2e1dfed861652e63377ba0999fe53bcce1398 Mon Sep 17 00:00:00 2001 From: Tom Lee Date: Tue, 3 Oct 2023 06:56:42 -0700 Subject: [PATCH] WIP - improve example app --- example/lib/components/bottom_button.dart | 30 +++++++++++++++++ example/lib/components/constants.dart | 41 +++++++++++++++++++++++ example/lib/main.dart | 34 ++++++++----------- 3 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 example/lib/components/bottom_button.dart create mode 100644 example/lib/components/constants.dart diff --git a/example/lib/components/bottom_button.dart b/example/lib/components/bottom_button.dart new file mode 100644 index 0000000..734aa9a --- /dev/null +++ b/example/lib/components/bottom_button.dart @@ -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, + ), + ), + ), + ); + } +} diff --git a/example/lib/components/constants.dart b/example/lib/components/constants.dart new file mode 100644 index 0000000..0d1ea27 --- /dev/null +++ b/example/lib/components/constants.dart @@ -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, +); diff --git a/example/lib/main.dart b/example/lib/main.dart index 2cd7fa9..d743eaa 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -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()); @@ -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'), ); } } @@ -66,27 +68,20 @@ class _MyHomePageState extends State { } _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}"); }); } @@ -132,13 +127,12 @@ class _MyHomePageState extends State { 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. ); }