-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Memo Creation CTA Empty State - closes #220
- Loading branch information
Showing
3 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 100 additions & 1 deletion
101
lib/application/pages/home/collections/update/update_collection_memos.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |