|
| 1 | +import 'package:flutter/widgets.dart'; |
| 2 | +import 'package:optimus/optimus.dart'; |
| 3 | +import 'package:optimus_widgetbook/components/chat/common.dart'; |
| 4 | +import 'package:widgetbook/widgetbook.dart'; |
| 5 | +import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; |
| 6 | + |
| 7 | +@widgetbook.UseCase( |
| 8 | + name: '', |
| 9 | + type: OptimusChatBubble, |
| 10 | + path: '[Forms]/Chat', |
| 11 | +) |
| 12 | +Widget createDefaultStyle(BuildContext context) { |
| 13 | + final k = context.knobs; |
| 14 | + final message = OptimusMessage( |
| 15 | + author: OptimusMessageAuthor( |
| 16 | + id: 'id', |
| 17 | + username: k.string(label: 'User name', initialValue: 'Doggo'), |
| 18 | + avatar: avatar2, |
| 19 | + ), |
| 20 | + message: k.string( |
| 21 | + label: 'Message', |
| 22 | + initialValue: |
| 23 | + 'Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm.', |
| 24 | + ), |
| 25 | + time: DateTime.now().subtract(const Duration(seconds: 30)), |
| 26 | + alignment: k.list( |
| 27 | + label: 'Alignment', |
| 28 | + initialOption: MessageAlignment.left, |
| 29 | + options: MessageAlignment.values, |
| 30 | + ), |
| 31 | + state: MessageState.sent, |
| 32 | + color: k.list( |
| 33 | + label: 'Color', |
| 34 | + initialOption: MessageColor.dark, |
| 35 | + options: MessageColor.values, |
| 36 | + ), |
| 37 | + ); |
| 38 | + |
| 39 | + return OptimusChatBubble( |
| 40 | + message: message, |
| 41 | + isUserNameVisible: k.boolean(label: 'Show user name', initialValue: true), |
| 42 | + isDateVisible: k.boolean(label: 'Show date', initialValue: true), |
| 43 | + formatTime: (DateTime input) => |
| 44 | + '${input.hour}:${input.minute.toString().padLeft(2, '0')}', |
| 45 | + formatDate: (DateTime input) => |
| 46 | + '${input.day}. ${input.month}. ${input.year}', |
| 47 | + sending: const Text('Sending...'), |
| 48 | + sent: const Text('Sent'), |
| 49 | + error: const Text('Error, try sending again'), |
| 50 | + ); |
| 51 | +} |
0 commit comments