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'),
);
}
}

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,12 +78,16 @@ class _BoguiState extends ConsumerState<Bogui> {
bottomOpacity: 0.5,
backgroundColor: orangeC,
title: Center(
child: Opacity(
opacity: 0.7,
child: Text(
widget.title,
style: const TextStyle(fontSize: 16),
style: const TextStyle(fontSize: 19, fontWeight: FontWeight.w600),
),
)),
),
body: Center(
body: Stack(children: [
Center(
child: SizedBox(
width: screenWidth,
child: Listener(
@ -178,8 +182,14 @@ class _BoguiState extends ConsumerState<Bogui> {
height: 45,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
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
@ -188,18 +198,22 @@ class _BoguiState extends ConsumerState<Bogui> {
_handleValidation();
},
child: ref.watch(gpt.isLoading)
? SizedBox(
? const SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
color: Colors.grey[800],
color: yellowC,
strokeWidth: 4,
),
)
: const Text(
'Valider',
: Text(
'Boguer',
style: TextStyle(
fontSize: 19, fontWeight: FontWeight.w500),
color: const Color.fromARGB(
255, 255, 255, 255)
.withOpacity(0.92),
fontSize: 19,
fontWeight: FontWeight.w500),
),
),
),
@ -207,7 +221,8 @@ class _BoguiState extends ConsumerState<Bogui> {
const SizedBox(height: 5),
const Text(
'ctrl + entrer',
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w100),
style:
TextStyle(fontSize: 11, fontWeight: FontWeight.w100),
),
const SizedBox(height: 40),
]),
@ -227,6 +242,27 @@ class _BoguiState extends ConsumerState<Bogui> {
),
),
),
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: