Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Date and/or Time #30

Open
s3ppo opened this issue Mar 22, 2021 · 2 comments
Open

Feature request: Date and/or Time #30

s3ppo opened this issue Mar 22, 2021 · 2 comments

Comments

@s3ppo
Copy link

s3ppo commented Mar 22, 2021

Hi any chance that you can add a field where i can provide the Date or/and Time....
i tried to insert a Column Widget with a second row, but positioning and styling looks pretty ugly

best regards
harald

@rafaelsetragni
Copy link

rafaelsetragni commented Apr 16, 2021

Try this one!

  return ListView.builder(
      reverse: true,
      padding: const EdgeInsets.only(left: 5, right: 5, top: 5, bottom: 10),
      itemCount: history!.messages.length,
      itemBuilder:  (context, index) {

        Message message = history!.messages[index];
        bool sent = widget.me == message.user;
        DateTime date = message.timestamp!.toLocal();
        int msgLength = message.msg.length;
        int limit = 35;

        return Bubble(
          style: sent ? styleMe : styleSomebody,
          child: Container(
            constraints: BoxConstraints(
                maxWidth: mediaQueryData.size.width * 0.7,
            ),
            child: Stack(
              children: [
                Padding(
                  padding: EdgeInsets.only(bottom: msgLength <= limit ? 0 : 18),
                  child: Text(
                      message.msg + (msgLength <= limit ? '             ' : ''),
                      style: DefaultTextStyle.of(context).style
                  ),
                ),
                Positioned(
                  bottom: 0,
                  right: 0,
                  child: Text(
                    dateFormatToday.format(date),
                    textAlign: TextAlign.end,
                    style: DefaultTextStyle.of(context).style.copyWith(fontSize: 12, color: Colors.grey.shade400)
                  ),
                )
              ],
            ),
          ),
        );
      }
  );

@s3ppo
Copy link
Author

s3ppo commented Apr 18, 2021

hi @rafaelsetragni thanks for your example code it is working great, but i am also using images inside.
it seems if there is a image .. the stack widget shows text under the image :(

here is my code:

Bubble(
  margin: BubbleEdges.only(top: 5, bottom: 5, left: 30),
  alignment: Alignment.topRight,
  nipWidth: 8,
  nipHeight: 10,
  nip: BubbleNip.rightTop,
  color: Color.fromRGBO(225, 255, 199, 1.0),
  child: Container(
                                  constraints:
                                      BoxConstraints(maxWidth: MediaQuery.of(context).size.width),
                                  child: Stack(
                                    children: [
                                      if (message.image != null && message.image != '') ...[
                                        showMessageImage(message.image, message.iId.oid)
                                      ],
                                      if (message.message != null && message.message != '') ...[
                                        Padding(
                                          padding:
                                              EdgeInsets.only(bottom: msgLength <= limit ? 0 : 18),
                                          child: Linkify(
                                              style: DefaultTextStyle.of(context).style,
                                              onOpen: _onOpen,
                                              text: message.message +
                                                  (msgLength <= limit ? '           ' : ''),
                                              textAlign: TextAlign.right),
                                        ),
                                      ],
                                      Positioned(
                                          bottom: -0.5,
                                          right: 0,
                                          child: Container(
                                            padding: EdgeInsets.only(right: 3),
                                            child: Text(
                                                DateFormat('HH:mm').format(
                                                    DateTime.fromMillisecondsSinceEpoch(
                                                        message.timestamp.date)),
                                                textAlign: TextAlign.end,
                                                style: DefaultTextStyle.of(context).style.copyWith(
                                                    fontSize: 12, color: Colors.grey.shade400)),
                                          ))
                                    ],
                                  ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants