wip: version number...

This commit is contained in:
poka 2023-02-22 22:23:01 +01:00
parent c21349bc60
commit 8d7714cf66
6 changed files with 226 additions and 139 deletions

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
// late StateProvider<String> appVersion;
// Colors
const Color orangeC = Color(0xffd07316);
const Color yellowC = Color(0xffFFD68E);

View File

@ -23,7 +23,7 @@ class MyApp extends StatelessWidget {
primaryColor: orangeC,
fontFamily: 'Georgia',
),
home: const Bogui(title: 'bogui'),
home: const Bogui(title: 'BoĞui'),
);
}
}
@ -41,4 +41,4 @@ double truncateDouble(double val, int decimals) {
valString = valString.substring(0, dotIndex + decimals + 1);
return double.parse(valString);
}
}

16
lib/riverpods/home.dart Normal file
View File

@ -0,0 +1,16 @@
// import 'package:flutter/material.dart';
import 'package:bogui/global.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:package_info_plus/package_info_plus.dart';
Future getAppVersion(WidgetRef ref) async {
final appVersion = StateProvider<String>((ref) => "...");
String version;
String buildNumber;
PackageInfo packageInfo = await PackageInfo.fromPlatform();
version = packageInfo.version;
buildNumber = packageInfo.buildNumber;
ref.read(appVersion.notifier).state = 'v$version+$buildNumber';
log.d(ref.read(appVersion));
return ref.read(appVersion);
}

View File

@ -1,12 +1,11 @@
import 'package:bogui/global.dart';
import 'package:bogui/riverpods/home.dart';
import 'package:bogui/riverpods/openai.dart';
import 'package:bogui/widgets/parameters_sliders.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:url_launcher/url_launcher.dart';
// import 'package:flutter/gestures.dart';
// import 'dart:math';
class Bogui extends ConsumerStatefulWidget {
const Bogui({super.key, required this.title});
@ -37,6 +36,7 @@ class _BoguiState extends ConsumerState<Bogui> {
Widget build(BuildContext context) {
final scrollController = ScrollController();
screenWidth = MediaQuery.of(context).size.width;
screenHight = MediaQuery.of(context).size.height;
return Scaffold(
appBar: AppBar(
leading: Row(
@ -78,155 +78,191 @@ class _BoguiState extends ConsumerState<Bogui> {
bottomOpacity: 0.5,
backgroundColor: orangeC,
title: Center(
child: Text(
widget.title,
style: const TextStyle(fontSize: 16),
child: Opacity(
opacity: 0.7,
child: Text(
widget.title,
style: const TextStyle(fontSize: 19, fontWeight: FontWeight.w600),
),
)),
),
body: Center(
child: SizedBox(
width: screenWidth,
child: Listener(
onPointerSignal: (_) {
// if (_ is PointerScrollEvent) {
// scrollController.jumpTo(
// max(
// min(
// scrollController.position.maxScrollExtent,
// scrollController.offset + _.scrollDelta.dx,
// ),
// scrollController.position.minScrollExtent,
// ),
// );
// }
},
child: SingleChildScrollView(
controller: scrollController,
child:
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Spacer(flex: screenWidth > 800 ? 3 : 2),
Column(children: <Widget>[
const SizedBox(height: 40),
Container(
constraints:
const BoxConstraints(minWidth: 500, maxWidth: 700),
width: screenWidth - 600,
child: CallbackShortcuts(
bindings: {
LogicalKeySet(LogicalKeyboardKey.control,
LogicalKeyboardKey.enter):
(() => _handleValidation()),
},
child: TextField(
autocorrect: false,
scrollPhysics: const NeverScrollableScrollPhysics(),
focusNode: promptFocus,
controller: ref.read(gpt.prompt),
autofocus: true,
textInputAction: TextInputAction.search,
// minLines: 3,
maxLines: null,
keyboardType: TextInputType.multiline,
cursorColor: orangeC,
style: const TextStyle(
color: Color.fromARGB(255, 223, 223, 223),
fontSize: 14,
letterSpacing: 0.1,
wordSpacing: 0.1,
),
decoration: InputDecoration(
filled: true,
helperText:
"Laissez-le autocompléter votre texte plutôt que de lui poser une question...",
helperStyle: const TextStyle(fontSize: 10),
hintText: "Qu'ils aillent tous se faire recompiler",
hintStyle: const TextStyle(
color: Color.fromARGB(255, 145, 145, 145),
fontWeight: FontWeight.w100,
fontSize: 14),
// fillColor: Colors.white,
prefixIconConstraints: const BoxConstraints(
minHeight: 32,
body: Stack(children: [
Center(
child: SizedBox(
width: screenWidth,
child: Listener(
onPointerSignal: (_) {
// if (_ is PointerScrollEvent) {
// scrollController.jumpTo(
// max(
// min(
// scrollController.position.maxScrollExtent,
// scrollController.offset + _.scrollDelta.dx,
// ),
// scrollController.position.minScrollExtent,
// ),
// );
// }
},
child: SingleChildScrollView(
controller: scrollController,
child:
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Spacer(flex: screenWidth > 800 ? 3 : 2),
Column(children: <Widget>[
const SizedBox(height: 40),
Container(
constraints:
const BoxConstraints(minWidth: 500, maxWidth: 700),
width: screenWidth - 600,
child: CallbackShortcuts(
bindings: {
LogicalKeySet(LogicalKeyboardKey.control,
LogicalKeyboardKey.enter):
(() => _handleValidation()),
},
child: TextField(
autocorrect: false,
scrollPhysics: const NeverScrollableScrollPhysics(),
focusNode: promptFocus,
controller: ref.read(gpt.prompt),
autofocus: true,
textInputAction: TextInputAction.search,
// minLines: 3,
maxLines: null,
keyboardType: TextInputType.multiline,
cursorColor: orangeC,
style: const TextStyle(
color: Color.fromARGB(255, 223, 223, 223),
fontSize: 14,
letterSpacing: 0.1,
wordSpacing: 0.1,
),
prefixIcon: const Padding(
padding: EdgeInsets.symmetric(horizontal: 17),
child: Icon(
Icons.agriculture_outlined,
color: orangeC,
size: 30,
)),
border: OutlineInputBorder(
decoration: InputDecoration(
filled: true,
helperText:
"Laissez-le autocompléter votre texte plutôt que de lui poser une question...",
helperStyle: const TextStyle(fontSize: 10),
hintText: "Qu'ils aillent tous se faire recompiler",
hintStyle: const TextStyle(
color: Color.fromARGB(255, 145, 145, 145),
fontWeight: FontWeight.w100,
fontSize: 14),
// fillColor: Colors.white,
prefixIconConstraints: const BoxConstraints(
minHeight: 32,
),
prefixIcon: const Padding(
padding: EdgeInsets.symmetric(horizontal: 17),
child: Icon(
Icons.agriculture_outlined,
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),
borderRadius: BorderRadius.circular(8)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey[500]!, width: 2.5),
borderRadius: BorderRadius.circular(8),
color: Colors.grey[500]!, width: 2.5),
borderRadius: BorderRadius.circular(8),
),
contentPadding: const EdgeInsets.all(20),
),
contentPadding: const EdgeInsets.all(20),
onSubmitted: (value) => promptFocus.requestFocus(),
),
onSubmitted: (value) => promptFocus.requestFocus(),
),
),
),
const SizedBox(height: 40),
Opacity(
opacity: 0.8,
child: SizedBox(
width: 200,
height: 45,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
),
onPressed:
ref.watch(gpt.prompt).text.length > 100000000000
? null
: () {
_handleValidation();
},
child: ref.watch(gpt.isLoading)
? SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
color: Colors.grey[800],
strokeWidth: 4,
),
)
: const Text(
'Valider',
style: TextStyle(
fontSize: 19, fontWeight: FontWeight.w500),
const SizedBox(height: 40),
Opacity(
opacity: 0.8,
child: SizedBox(
width: 200,
height: 45,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(7),
),
),
foregroundColor: Colors.white, elevation: 0,
backgroundColor:
orangeC.withOpacity(0.9), // foreground
),
onPressed:
ref.watch(gpt.prompt).text.length > 100000000000
? null
: () {
_handleValidation();
},
child: ref.watch(gpt.isLoading)
? const SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
color: yellowC,
strokeWidth: 4,
),
)
: Text(
'Boguer',
style: TextStyle(
color: const Color.fromARGB(
255, 255, 255, 255)
.withOpacity(0.92),
fontSize: 19,
fontWeight: FontWeight.w500),
),
),
),
),
),
const SizedBox(height: 5),
const Text(
'ctrl + entrer',
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w100),
),
const SizedBox(height: 40),
const SizedBox(height: 5),
const Text(
'ctrl + entrer',
style:
TextStyle(fontSize: 11, fontWeight: FontWeight.w100),
),
const SizedBox(height: 40),
]),
const Spacer(),
if (screenWidth > 800)
Column(
children: [
CustomSlider(
parameter: gpt.temperature,
nameParameter: 'Température',
),
],
),
const Spacer(),
]),
const Spacer(),
if (screenWidth > 800)
Column(
children: [
CustomSlider(
parameter: gpt.temperature,
nameParameter: 'Température',
),
],
),
const Spacer(),
]),
),
),
),
),
),
Positioned(
left: 15,
top: screenHight - 80,
child: FutureBuilder(
future: getAppVersion(ref),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Text(
snapshot.data,
style: const TextStyle(
fontSize: 9,
color: Color.fromARGB(255, 216, 216, 216),
fontWeight: FontWeight.w100),
);
} else {
return const Text('...');
}
},
),
),
]),
);
}
}

View File

@ -57,6 +57,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter:
dependency: "direct main"
description: flutter
@ -177,6 +185,22 @@ packages:
url: "https://github.com/morriskurz/openai_gpt3_dart_api.git"
source: git
version: "0.1.3"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
sha256: "8df5ab0a481d7dc20c0e63809e90a588e496d276ba53358afc4c4443d0a00697"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
path:
dependency: transitive
description:
@ -342,6 +366,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
win32:
dependency: transitive
description:
name: win32
sha256: "5cdbe09a75b5f4517adf213c68aaf53ffa162fadf54ba16f663f94f3d2664a56"
url: "https://pub.dev"
source: hosted
version: "4.1.1"
sdks:
dart: ">=2.18.6 <3.0.0"
flutter: ">=3.3.0"

View File

@ -5,7 +5,7 @@ description: Qu'ils aillent tous se faire enculer.
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.1+2
version: 0.0.2+3
environment:
sdk: '>=2.18.6 <3.0.0'
@ -22,6 +22,7 @@ dependencies:
flutter_riverpod: ^2.1.3
logger: ^1.1.0
url_launcher:
package_info_plus: ^3.0.2
dev_dependencies:
flutter_test: