Skip to content

Commit

Permalink
feat: Design System (#7)
Browse files Browse the repository at this point in the history
* Add catalog

* buttons, text inputs and catalog

* add obscure property to textfields

* support leading icon null

* Use snackbar, rename text input

* fix linter

* change colors

* change text size
  • Loading branch information
cecipirotto authored Oct 13, 2023
1 parent 6cbb9eb commit b809c87
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 9 deletions.
133 changes: 133 additions & 0 deletions supabase-ws-flutter-mobile/lib/catalog_main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:flutter_template/core/common/logger.dart';
import 'package:flutter_template/ui/resources.dart';
import 'package:flutter_template/ui/theme/app_theme.dart';
import 'package:flutter_template/ui/widgets/design_system/buttons/base_button.dart';
import 'package:flutter_template/ui/widgets/design_system/buttons/primary_button.dart';
import 'package:flutter_template/ui/widgets/design_system/text_fields/input_text.dart';

void main() {
runZonedGuarded(
() {
runApp(const MyCatalogApp());
},
(exception, stackTrace) =>
Logger.fatal(error: exception, stackTrace: stackTrace),
);
}

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

@override
Widget build(BuildContext context) => ScreenUtilInit(
designSize: const Size(375, 812),
minTextAdapt: false,
splitScreenMode: true,
builder: (_, __) => const _CatalogAppContentScreen(),
);
}

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

@override
State<_CatalogAppContentScreen> createState() =>
_CatalogAppContentScreenState();
}

class _CatalogAppContentScreenState extends State<_CatalogAppContentScreen> {
final _messengerKey = GlobalKey<ScaffoldMessengerState>();

@override
Widget build(BuildContext context) => MaterialApp(
scaffoldMessengerKey: _messengerKey,
home: SafeArea(
child: Scaffold(
body: Padding(
padding: const EdgeInsets.all(20.0),
child: ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: AppPrimaryButton(
text: 'Filled Button',
onPressed: () {
_messengerKey.currentState?.showSnackBar(
const SnackBar(
content: Text('Filled button pressed!'),
),
);
},
style: StyleButton.filled,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: AppPrimaryButton(
text: 'Stroke Button',
onPressed: () {
_messengerKey.currentState?.showSnackBar(
const SnackBar(
content: Text('Stroke button pressed!'),
),
);
},
style: StyleButton.stroke,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: AppPrimaryButton(
text: 'Ghost Button',
onPressed: () {
_messengerKey.currentState?.showSnackBar(
const SnackBar(
content: Text('Ghost button pressed!'),
),
);
},
style: StyleButton.ghost,
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: AppTextInputField(
hintText: 'Write your text...',
labelText: 'Label',
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16.0),
child: AppTextInputField(
hintText: 'Write your text...',
labelText: 'Label',
error: 'Error text',
),
),
],
),
),
),
),
builder: (context, child) {
Resources.setup(context);
return child!;
},
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
theme: AppTheme.provideAppTheme(context),
);
}
18 changes: 9 additions & 9 deletions supabase-ws-flutter-mobile/lib/ui/theme/app_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AppColors extends ColorScheme {
static AppColors getColorScheme() => AppColors(
colorScheme: ColorScheme.fromSeed(
seedColor: const MaterialColor(
0x0E9F6F,
0xFF0E9F6F,
<int, Color>{
100: Color.fromRGBO(248, 254, 252, 1),
200: Color.fromRGBO(225, 247, 240, 1),
Expand All @@ -73,7 +73,7 @@ class AppColors extends ColorScheme {
),
brightness: Brightness.dark,
primary: const MaterialColor(
0x0E9F6F,
0xFF0E9F6F,
<int, Color>{
100: Color.fromRGBO(248, 254, 252, 1),
200: Color.fromRGBO(225, 247, 240, 1),
Expand All @@ -89,7 +89,7 @@ class AppColors extends ColorScheme {
),
onPrimary: Colors.white,
secondary: const MaterialColor(
0xE0E0E0,
0xFFE0E0E0,
<int, Color>{
100: Color.fromRGBO(255, 255, 255, 1),
200: Color.fromRGBO(249, 249, 249, 1),
Expand All @@ -105,7 +105,7 @@ class AppColors extends ColorScheme {
),
onSecondary: Colors.black,
background: const MaterialColor(
0x0B0C0D,
0xFF0B0C0D,
<int, Color>{
100: Color.fromRGBO(163, 170, 177, 1),
200: Color.fromRGBO(138, 145, 153, 1),
Expand All @@ -118,7 +118,7 @@ class AppColors extends ColorScheme {
surface: Colors.black,
onSurface: Colors.white,
textColor: const MaterialColor(
0xFFFFFF,
0xFFFFFFFF,
<int, Color>{
100: Color.fromRGBO(255, 255, 255, 1),
200: Color.fromRGBO(194, 194, 204, 1),
Expand All @@ -128,7 +128,7 @@ class AppColors extends ColorScheme {
},
),
success: const MaterialColor(
0x10B981,
0xFF10B981,
<int, Color>{
100: Color.fromRGBO(231, 248, 242, 1),
200: Color.fromRGBO(159, 227, 205, 1),
Expand All @@ -138,7 +138,7 @@ class AppColors extends ColorScheme {
},
),
info: const MaterialColor(
0x1169F7,
0xFF1169F7,
<int, Color>{
100: Color.fromRGBO(207, 232, 254, 1),
200: Color.fromRGBO(111, 176, 252, 1),
Expand All @@ -148,7 +148,7 @@ class AppColors extends ColorScheme {
},
),
warning: const MaterialColor(
0xF59E0B,
0xFFF59E0B,
<int, Color>{
100: Color.fromRGBO(254, 245, 231, 1),
200: Color.fromRGBO(251, 216, 157, 1),
Expand All @@ -158,7 +158,7 @@ class AppColors extends ColorScheme {
},
),
error: const MaterialColor(
0xF4444,
0xFF0E9F6F,
<int, Color>{
100: Color.fromRGBO(253, 236, 236, 1),
200: Color.fromRGBO(249, 180, 180, 1),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'package:flutter_template/ui/extensions/context_extensions.dart';
import 'package:flutter_template/ui/theme/app_theme.dart';
import 'package:flutter_template/ui/theme/text_styles.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AppBaseButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final Color backgroundColor;
final Color textColor;
final Color focusColor;
final Color disabledTextColor;
final Color pressedColor;
final Color disabledColor;
final Color hoveredColor;
final Color? borderSideColor;
final Icon? iconLeft;
final Icon? iconRight;
final double verticalPadding;

const AppBaseButton({
required this.text,
required this.onPressed,
required this.backgroundColor,
required this.textColor,
required this.disabledColor,
required this.focusColor,
required this.pressedColor,
required this.disabledTextColor,
required this.hoveredColor,
this.borderSideColor,
this.iconLeft,
this.iconRight,
this.verticalPadding = 12,
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) => MaterialButton(
minWidth: 100.w,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(28.r),
side: BorderSide(
width: 2,
color: borderSideColor ?? Colors.transparent,
),
),
elevation: 0.0,
color: backgroundColor,
disabledColor: disabledColor,
disabledTextColor: disabledTextColor,
highlightColor: pressedColor,
textColor: textColor,
onPressed: onPressed,
hoverColor: hoveredColor,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (iconLeft != null)
Container(
margin: EdgeInsets.only(right: 16.w),
child: iconLeft,
),
Padding(
padding: EdgeInsets.symmetric(
vertical: verticalPadding.h,
),
child: Text(
text,
style: context.theme.textStyles.bodySmall
?.semibold()
.copyWith(color: textColor),
),
),
if (iconRight != null)
Container(
margin: EdgeInsets.only(left: 16.w),
child: iconRight,
),
],
),
);
}

enum StyleButton {
filled,
stroke,
ghost,
}
Loading

0 comments on commit b809c87

Please sign in to comment.