Skip to content

Commit

Permalink
Adds Memo Creation CTA Empty State - closes #220
Browse files Browse the repository at this point in the history
  • Loading branch information
ggirotto committed Nov 17, 2021
1 parent 7f2b337 commit 035a847
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/application/constants/dimensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ const double tagsRemoveIconSize = 12;
// Terminal Window
//
const double terminalWindowHeaderHeight = 64;

//
// Create Memo CTA
//
const double createMemoCtaSide = 64;
const double createMemoCtaButtonStrokeWidth = 3;
2 changes: 2 additions & 0 deletions lib/application/constants/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ const remove = 'Remover';
const removeMemoTitle = 'Remover Memo';
const removeMemoMessage = 'Você tem certeza que deseja remover este memo?';

const newMemo = 'Novo Memo';

//
// Tags Component
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,107 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:layoutr/common_layout.dart';
import 'package:memo/application/constants/dimensions.dart' as dimens;
import 'package:memo/application/constants/images.dart' as images;
import 'package:memo/application/constants/strings.dart' as strings;
import 'package:memo/application/theme/theme_controller.dart';

class UpdateCollectionMemos extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(color: Colors.blue, child: Center(child: Text('Memos')));
return _CreateMemoEmptyState(
onTap: () {
print("teste");
},
);
}
}

/// An empty state CTA to add a new `Memo` to a `Collection`.
class _CreateMemoEmptyState extends ConsumerWidget {
const _CreateMemoEmptyState({this.onTap});

final VoidCallback? onTap;

@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = useTheme(ref);
final textTheme = Theme.of(context).textTheme;

return Material(
child: InkWell(
onTap: onTap,
child: Ink(
decoration: BoxDecoration(
border: Border.all(color: theme.neutralSwatch.shade700, width: dimens.genericBorderHeight),
borderRadius: dimens.executionsTerminalBorderRadius,
color: theme.neutralSwatch.shade800,
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CustomPaint(
size: const Size(dimens.createMemoCtaSide, dimens.createMemoCtaSide),
painter: _CreateButtonPainter(
backgroundColor: theme.primarySwatch.shade400,
createColor: theme.neutralSwatch.shade800,
),
),
context.verticalBox(Spacing.small),
Text(
strings.newMemo.toUpperCase(),
style: textTheme.button?.copyWith(color: theme.primarySwatch.shade400),
textAlign: TextAlign.center,
)
],
),
),
),
),
);
}
}

class _CreateButtonPainter extends CustomPainter {
_CreateButtonPainter({required this.backgroundColor, required this.createColor});

final Color backgroundColor;
final Color createColor;

@override
void paint(Canvas canvas, Size size) {
final backgroundPaint = Paint()..color = backgroundColor;
final bounds = Rect.fromLTWH(0, 0, size.width, size.height);

final backgroundCircle = Path()
..addOval(
Rect.fromCircle(
center: bounds.center,
radius: bounds.height / 2,
),
);

canvas.drawPath(backgroundCircle, backgroundPaint);

final stripsPainter = Paint()
..color = createColor
..strokeWidth = dimens.createMemoCtaButtonStrokeWidth
..style = PaintingStyle.fill
..strokeCap = StrokeCap.round;

final xCenter = size.width / 2;
final yCenter = size.height / 2;

final xQuarter = size.width / 3.5;
final yQuarter = size.height / 3.5;

canvas
..drawLine(Offset(xCenter, yQuarter), Offset(xCenter, size.height - yQuarter), stripsPainter)
..drawLine(Offset(xQuarter, yCenter), Offset(size.width - xQuarter, yCenter), stripsPainter);
}

@override
bool shouldRepaint(_CreateButtonPainter oldDelegate) =>
backgroundColor != oldDelegate.backgroundColor || createColor != oldDelegate.createColor;
}

0 comments on commit 035a847

Please sign in to comment.