bogui/lib/screens/home.dart

95 lines
3.0 KiB
Dart
Raw Normal View History

2023-01-07 13:02:53 +01:00
import 'package:bogui/global.dart';
import 'package:bogui/riverpods/openai.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class Bogui extends ConsumerStatefulWidget {
const Bogui({super.key, required this.title});
final String title;
@override
ConsumerState<Bogui> createState() => _BoguiState();
}
class _BoguiState extends ConsumerState<Bogui> {
late OpenAI gpt;
@override
void initState() {
gpt = OpenAI();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 800,
child: TextField(
controller: ref.watch(gpt.prompt),
autofocus: true,
textInputAction: TextInputAction.search,
minLines: 3,
maxLines: 9,
cursorColor: orangeC,
style: TextStyle(color: Colors.grey[400], fontSize: 18),
decoration: InputDecoration(
filled: true,
// fillColor: Colors.white,
prefixIconConstraints: const BoxConstraints(
minHeight: 32,
),
prefixIcon: const Padding(
padding: EdgeInsets.symmetric(horizontal: 17),
child: Icon(
Icons.fireplace_rounded,
color: orangeC,
size: 30,
)),
border: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey[500]!, width: 2),
borderRadius: BorderRadius.circular(8)),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey[500]!, width: 2.5),
borderRadius: BorderRadius.circular(8),
),
contentPadding: const EdgeInsets.all(20),
),
onSubmitted: (value) => gpt.completionEasy(ref),
),
),
const SizedBox(height: 40),
SizedBox(
width: 250,
height: 50,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
),
onPressed: () {
gpt.completionEasy(ref);
},
child: const Text(
'Valider',
style: TextStyle(fontSize: 21, fontWeight: FontWeight.w500),
),
),
),
],
),
),
);
}
}