Skip to content

DOCINFRA-2341_merged_using_automation #1043

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

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions Flutter/assistview/action-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ If no composer is added (by specifying the composer as null), the action button
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -38,6 +54,23 @@ The [child] property allows you to define a custom widget consisting of one or m
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
child: const Icon(Icons.chat),
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -48,6 +81,38 @@ It is a callback that is invoked whenever the action button is pressed. Since th
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

void _generativeResponse(String data) async {
final String response = await _getAIResponse(data);
setState(() {
_messages.add(AssistMessage.response(data: response));
});
}

Future<String> _getAIResponse(String data) async {
String response = '';
// Connect with your preferred AI to generate a response to the request.
return response;
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
onPressed: (String data) {
setState(() {
_messages.add(AssistMessage.request(data: data));
_generativeResponse(data);
});
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -58,6 +123,23 @@ The [`tooltip`] text describes the button's action when pressed. It is displayed
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
tooltip: 'Send Message',
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -76,6 +158,27 @@ The [`splashColor`] property is the splash color of the button's InkWell. The de
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
foregroundColor: Colors.white,
backgroundColor: Colors.blue,
focusColor: Colors.lightBlueAccent,
hoverColor: Colors.blueAccent,
splashColor: Colors.white.withOpacity(0.3),
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -92,6 +195,26 @@ The [`highlightElevation`] property determines the elevation when the button is
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
elevation: 2.0,
focusElevation: 6.0,
hoverElevation: 4.0,
highlightElevation: 8.0,
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -102,6 +225,23 @@ The [`mouseCursor`] property defines the type of cursor that appears when hoveri
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
mouseCursor: SystemMouseCursors.forbidden,
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -112,6 +252,30 @@ The [`shape`] property sets the shape of the button's border, such as rounded or
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
shape: const ContinuousRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(15),
bottomRight: Radius.circular(30.0),
bottomLeft: Radius.circular(15)
),
),
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -122,6 +286,23 @@ The [`padding`] property defines the space inside the button between its border
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
padding: const EdgeInsetsDirectional.only(start: 8.0),
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand All @@ -132,6 +313,23 @@ The [`size`] property specifies the width and height of the button. By default,
{% tabs %}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

@override
Widget build(BuildContext context) {
return Scaffold(
body: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
size: const Size.square(40.0),
onPressed: (String data) {
// Handle the send button click action here.
},
),
),
);
}

{% endhighlight %}
{% endtabs %}

Expand Down
Loading