Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR Code-Enabled Form Submission Component for Flutter: Simplifying Digital Interactions #379

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions core-services/digit-components/Components
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
The list of components used in DIGIT-Design are:
1. HEADER
2. BACK LINK
3. BREAD CRUMBS
4. BUTTONS
5. CHECKBOX
6. PANEL
7. RADIO
8. SELECT
9. TEXT INPUT
10. INSERT TEXT
11. SIDE NAV
12. TOAST
13. POP-UP
14. TAG
15. TABS
16. TABLE
17. SUMMARY LIST
18. PAGINATION
19. DATE INPUT
20. ERROR MESSAGE
21. SKIP LINK
22. FILE UPLOAD
23. FOOTER
24. PHASE BANNER
25. NOTIFICATION BANNER
19 changes: 19 additions & 0 deletions core-services/digit-components/Header
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Overview:
A header is a term given to a main strip or icon that sits towards the top of your website. Its purpose is to introduce your branding and send out a message.

When to apply?
1. Apply the header component when you require consistent navigation across multiple pages or sections within your digital product or service.
2. When you need to display branding elements such as logos or brand colors prominently at the top of the page.
3. When you have multiple navigation links that need to be easily accessible to users.
4. When you need flexibility in customizing the appearance and behavior of the navigation interface.

When Not to Apply?
1. In single-page applications where a persistent header is unnecessary.
2. In contexts where screen space is limited and a compact navigation solution is more suitable.
3. When non-standard navigation patterns are required that are not supported by the header component.

How to Apply?
1. Integrate the header component into the project's layout or template.
2. Customize the header component using props such as logo, navigation links, and theme.
3. Test the header component for functionality, responsiveness, and accessibility.
4. Document usage guidelines and customization options for reference.
106 changes: 106 additions & 0 deletions core-services/digit-components/button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Button Types Example',
home: Scaffold(
appBar: AppBar(
title: Text('Button Types Example'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DefaultButton(text: 'Save and Continue'),
SizedBox(height: 10),
SecondaryButton(text: 'Cancel'),
SizedBox(height: 10),
MultiButton(text: 'Download', subActions: ['PDF', 'Excel', 'CSV']),
SizedBox(height: 10),
DisableButton(text: 'Disabled', onPressed: null),
],
),
),
),
);
}
}

class DefaultButton extends StatelessWidget {
final String text;

DefaultButton({required this.text});

@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {},
child: Text(text),
);
}
}

class SecondaryButton extends StatelessWidget {
final String text;

SecondaryButton({required this.text});

@override
Widget build(BuildContext context) {
return TextButton(
onPressed: () {},
child: Text(text),
);
}
}

class MultiButton extends StatelessWidget {
final String text;
final List<String> subActions;

MultiButton({required this.text, required this.subActions});

@override
Widget build(BuildContext context) {
return PopupMenuButton(
itemBuilder: (BuildContext context) {
return subActions.map((String action) {
return PopupMenuItem(
child: Text(action),
value: action,
);
}).toList();
},
child: ElevatedButton(
onPressed: () {},
child: Text(text),
),
);
}
}

class DisableButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;

DisableButton({required this.text, required this.onPressed});

@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onPressed,
child: Text(text),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(Colors.grey),
textStyle: MaterialStateProperty.all<TextStyle>(TextStyle(color: Colors.white)),
),
);
}
}
63 changes: 63 additions & 0 deletions core-services/digit-components/error-message.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
final TextEditingController _textController = TextEditingController();
String _errorMessage = '';

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Error Message Example',
home: Scaffold(
appBar: AppBar(
title: Text('Error Message Example'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: _textController,
decoration: InputDecoration(
labelText: 'Enter your name',
errorText: _errorMessage.isNotEmpty ? _errorMessage : null,
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
// Validate input and display error message if necessary
String input = _textController.text.trim();
if (input.isEmpty) {
setState(() {
_errorMessage = 'Name cannot be empty';
});
} else {
setState(() {
_errorMessage = '';
});
// Proceed with other actions
}
},
child: Text('Submit'),
),
],
),
),
),
),
);
}
}
91 changes: 91 additions & 0 deletions core-services/digit-components/header.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// This Flutter code creates a basic header with a blue background color, white text, a logo placeholder (labeled as
//'YourLogo'), and navigation links ('Home', 'About', 'Services', 'Contact'). You can further customize it according
// to your design requirements.


//general header format
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Header Design',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}

class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: Row(
children: [
Text(
'YourLogo',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Spacer(),
NavLinks(),
],
),
),
body: Center(
child: Text(
'Your Content Here',
style: TextStyle(fontSize: 20),
),
),
);
}
}

class NavLinks extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
children: [
NavItem(text: 'Home'),
NavItem(text: 'About'),
NavItem(text: 'Services'),
NavItem(text: 'Contact'),
],
);
}
}

class NavItem extends StatelessWidget {
final String text;

NavItem({required this.text});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
text,
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
);
}
}


60 changes: 60 additions & 0 deletions core-services/digit-components/toast.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// First,add the fluttertoast package to your pubspec.yaml file:

// dependencies:
// flutter:
// sdk: flutter
// fluttertoast: ^8.0.8


import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Toast Example',
home: Scaffold(
appBar: AppBar(
title: Text('Toast Example'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
// Display success toast
showToast('Action completed successfully', Colors.green, Icons.check);
},
child: Text('Show Toast'),
),
),
),
);
}

void showToast(String message, Color backgroundColor, IconData icon) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: backgroundColor,
textColor: Colors.white,
fontSize: 16.0,
timeInSecForIosWeb: 1,
webShowClose: true,
webPosition: 'center',
webBgColor: '#e74c3c',
// Set an icon before the text
child: Row(
children: [
Icon(icon),
SizedBox(width: 8),
Text(message),
],
),
);
}
}
Loading