CAKE-28 | reworked exchange confirm page; applied light and dark themes to exchange confirm page, currency picker, picker, base alert dialog, alert with one action; applied maximum characters parameter to crypto currency text field in the exchange card

This commit is contained in:
Oleksandr Sobol
2020-08-25 21:12:14 +03:00
parent 40aeacfb4b
commit ecf7a5ba78
15 changed files with 404 additions and 341 deletions
+3 -8
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
import 'package:cake_wallet/palette.dart';
class AlertWithOneAction extends BaseAlertDialog {
AlertWithOneAction({
@@ -31,13 +32,7 @@ class AlertWithOneAction extends BaseAlertDialog {
width: 300,
height: 52,
padding: EdgeInsets.only(left: 12, right: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(24),
bottomRight: Radius.circular(24)
),
color: Colors.white
),
color: Palette.blueCraiola,
child: ButtonTheme(
minWidth: double.infinity,
child: FlatButton(
@@ -50,7 +45,7 @@ class AlertWithOneAction extends BaseAlertDialog {
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Colors.blue,
color: Colors.white,
decoration: TextDecoration.none,
),
)),
+52 -81
View File
@@ -17,6 +17,7 @@ class BaseAlertDialog extends StatelessWidget {
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
@@ -30,7 +31,7 @@ class BaseAlertDialog extends StatelessWidget {
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
fontFamily: 'Poppins',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
@@ -38,55 +39,39 @@ class BaseAlertDialog extends StatelessWidget {
}
Widget actionButtons(BuildContext context) {
return Container(
width: 300,
height: 52,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(24),
bottomRight: Radius.circular(24)
),
color: Colors.white
),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Flexible(
return Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Flexible(
child: Container(
height: 52,
padding: EdgeInsets.only(left: 12, right: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(24)),
),
color: Palette.blueCraiola,
child: ButtonTheme(
minWidth: double.infinity,
child: FlatButton(
onPressed: actionLeft,
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
child: Text(
leftActionButtonText,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: Colors.blue,
decoration: TextDecoration.none,
),
)),
onPressed: actionLeft,
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
child: Text(
leftActionButtonText,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
color: Colors.white,
decoration: TextDecoration.none,
),
)),
),
)
),
Container(
height: 52,
width: 1,
color: Colors.grey.withOpacity(0.2),
),
Flexible(
),
Flexible(
child: Container(
height: 52,
padding: EdgeInsets.only(left: 12, right: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomRight: Radius.circular(24)),
),
color: Palette.alizarinRed,
child: ButtonTheme(
minWidth: double.infinity,
child: FlatButton(
@@ -98,16 +83,16 @@ class BaseAlertDialog extends StatelessWidget {
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
color: Colors.red,
color: Colors.white,
decoration: TextDecoration.none,
),
)),
),
)
)
],
),
)
],
);
}
@@ -126,44 +111,30 @@ class BaseAlertDialog extends StatelessWidget {
child: Center(
child: GestureDetector(
onTap: () => null,
child: Container(
width: 300,
height: 257,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(24)),
color: Theme.of(context).accentTextTheme.title.backgroundColor
),
child: Column(
children: <Widget>[
Container(
width: 300,
height: 77,
padding: EdgeInsets.only(left: 24, right: 24),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24)
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(30)),
child: Container(
width: 300,
color: Theme.of(context).accentTextTheme.title.decorationColor,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(24, 32, 24, 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
title(context),
Padding(
padding: EdgeInsets.only(top: 8),
child: content(context),
)
],
),
),
child: Center(
child: title(context),
),
),
Container(
width: 300,
height: 1,
color: Theme.of(context).dividerColor,
),
Container(
width: 300,
height: 127,
padding: EdgeInsets.all(24),
child: Center(
child: content(context),
),
),
actionButtons(context)
],
actionButtons(context)
],
),
),
),
),
+4 -1
View File
@@ -21,7 +21,8 @@ class BaseTextFormField extends StatelessWidget {
this.enabled = true,
this.validator,
this.textStyle,
this.placeholderTextStyle});
this.placeholderTextStyle,
this.maxLength});
final TextEditingController controller;
final TextInputType keyboardType;
@@ -42,6 +43,7 @@ class BaseTextFormField extends StatelessWidget {
final FormFieldValidator<String> validator;
final TextStyle placeholderTextStyle;
final TextStyle textStyle;
final int maxLength;
@override
Widget build(BuildContext context) {
@@ -54,6 +56,7 @@ class BaseTextFormField extends StatelessWidget {
maxLines: maxLines,
inputFormatters: inputFormatters,
enabled: enabled,
maxLength: maxLength,
style: textStyle ?? TextStyle(
fontSize: 16.0,
color: textColor ?? Theme.of(context).primaryTextTheme.title.color),
+98 -56
View File
@@ -1,15 +1,20 @@
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/src/widgets/alert_background.dart';
import 'package:cake_wallet/src/widgets/cake_scrollbar.dart';
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
import 'package:cake_wallet/palette.dart';
class Picker<Item extends Object> extends StatelessWidget {
class Picker<Item extends Object> extends StatefulWidget {
Picker({
@required this.selectedAtIndex,
@required this.items,
this.images,
@required this.title,
@required this.onItemSelected,
this.mainAxisAlignment = MainAxisAlignment.start
this.mainAxisAlignment = MainAxisAlignment.start,
this.isAlwaysShowScrollThumb = false
});
final int selectedAtIndex;
@@ -18,59 +23,87 @@ class Picker<Item extends Object> extends StatelessWidget {
final String title;
final Function(Item) onItemSelected;
final MainAxisAlignment mainAxisAlignment;
final bool isAlwaysShowScrollThumb;
@override
PickerState createState() => PickerState<Item>(items, images, onItemSelected);
}
class PickerState<Item> extends State<Picker> {
PickerState(this.items, this.images, this.onItemSelected);
final Function(Item) onItemSelected;
final List<Item> items;
final List<Image> images;
final closeButton = Image.asset('assets/images/close.png',
color: Palette.darkBlueCraiola,
);
ScrollController controller = ScrollController();
final double backgroundHeight = 193;
final double thumbHeight = 72;
double fromTop = 0;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => Navigator.of(context).pop(),
child: Container(
color: Colors.transparent,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
child: Container(
decoration: BoxDecoration(color: PaletteDark.darkNightBlue.withOpacity(0.75)),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 24, right: 24),
child: Text(
title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
color: Colors.white
),
),
controller.addListener(() {
fromTop = controller.hasClients
? (controller.offset / controller.position.maxScrollExtent * (backgroundHeight - thumbHeight))
: 0;
setState(() {});
});
return AlertBackground(
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 24, right: 24),
child: Text(
widget.title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18,
fontFamily: 'Poppins',
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
color: Colors.white
),
Padding(
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
child: GestureDetector(
onTap: () => null,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(14)),
child: Container(
height: 233,
color: Theme.of(context).accentTextTheme.title.backgroundColor,
child: ListView.separated(
),
),
Padding(
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
child: GestureDetector(
onTap: () => null,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(14)),
child: Container(
height: 233,
color: Theme.of(context).accentTextTheme.title.color,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
ListView.separated(
controller: controller,
separatorBuilder: (context, index) => Divider(
color: Theme.of(context).dividerColor,
color: Theme.of(context).accentTextTheme.title.backgroundColor,
height: 1,
),
itemCount: items == null ? 0 : items.length,
itemBuilder: (context, index) {
final item = items[index];
final image = images != null? images[index] : null;
final isItemSelected = index == selectedAtIndex;
final isItemSelected = index == widget.selectedAtIndex;
final color = isItemSelected
? Theme.of(context).accentTextTheme.subtitle.decorationColor
: Colors.transparent;
? Theme.of(context).textTheme.body2.color
: Theme.of(context).accentTextTheme.title.color;
final textColor = isItemSelected
? Colors.blue
? Palette.blueCraiola
: Theme.of(context).primaryTextTheme.title.color;
return GestureDetector(
@@ -87,21 +120,22 @@ class Picker<Item extends Object> extends StatelessWidget {
color: color,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: mainAxisAlignment,
mainAxisAlignment: widget.mainAxisAlignment,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
image != null
? image
: Offstage(),
? image
: Offstage(),
Padding(
padding: EdgeInsets.only(
left: image != null ? 12 : 0
left: image != null ? 12 : 0
),
child: Text(
item.toString(),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
color: textColor,
decoration: TextDecoration.none,
),
@@ -112,17 +146,25 @@ class Picker<Item extends Object> extends StatelessWidget {
),
);
},
),
widget.isAlwaysShowScrollThumb
? CakeScrollbar(
backgroundHeight: backgroundHeight,
thumbHeight: thumbHeight,
fromTop: fromTop
)
),
),
: Offstage(),
],
)
),
)
],
),
)
),
),
),
),
),
)
],
),
AlertCloseButton(image: closeButton)
],
)
);
}
}
}