Widget build()

in gemini/sample-apps/photo-discovery/app/lib/ui/screens/chat.dart [110:182]


  Widget build(BuildContext context) {
    var metadata = context.watch<AppState>().metadata;

    Widget? suggestionsWidget;

    if (metadata != null) {
      if (_messages.length == 1) {
        suggestionsWidget = Padding(
          padding: const EdgeInsets.fromLTRB(16, 24, 16, 8),
          child: TagCapsule(
            onTap: _pickSuggestedQuestion,
            title: 'Suggested Questions',
            tags: metadata.suggestedQuestions,
          ),
        );
      }
    }

    List<types.User> typingUsers = [];

    if (loading) typingUsers.add(_agent);

    return Column(
      children: [
        AppBar(
          title: const Text('Chat with AI'),
          actions: (widget.onExit != null)
              ? [
                  Padding(
                    padding: const EdgeInsets.all(8),
                    child: IconButton(
                      color: Theme.of(context).colorScheme.secondary,
                      onPressed: widget.onExit,
                      icon: const Icon(
                        size: 28,
                        FontAwesomeIcons.circleXmark,
                      ),
                    ),
                  )
                ]
              : [],
        ),
        Expanded(
          child: Chat(
            typingIndicatorOptions: TypingIndicatorOptions(
              typingUsers: typingUsers,
            ),
            listBottomWidget: suggestionsWidget,
            messages: _messages,
            onSendPressed: _handleSendPressed,
            showUserAvatars: true,
            showUserNames: true,
            user: _user,
            theme: DefaultChatTheme(
              receivedMessageBodyTextStyle: TextStyle(
                color: Theme.of(context).colorScheme.onSurface,
              ),
              sentMessageBodyTextStyle: TextStyle(
                color: Theme.of(context).colorScheme.onSecondary,
              ),
              userAvatarNameColors: [
                Theme.of(context).colorScheme.primary,
              ],
              backgroundColor:
                  Theme.of(context).colorScheme.surfaceContainerHigh,
              primaryColor: Theme.of(context).colorScheme.primary,
              secondaryColor: Theme.of(context).colorScheme.surface,
            ),
          ),
        ),
      ],
    );
  }