Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
djeddi-yacine committed Oct 11, 2023
2 parents b66c9e8 + 33e90db commit 7e66d3a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 21 deletions.
6 changes: 3 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 33
ndkVersion flutter.ndkVersion

compileOptions {
Expand All @@ -47,8 +47,8 @@ android {
applicationId "com.example.fusion_brain_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
minSdkVersion 21
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
45 changes: 37 additions & 8 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// Importing the 'dart:io' package to detect the platform, the 'brain_fusion' package for AI processing, the 'flutter/foundation.dart' package for debugging, and the 'flutter/material.dart' package for widget building.import 'dart:io' show Platform;
// ignore_for_file: prefer_const_constructors

import 'dart:io' show Platform;
import 'package:brain_fusion/brain_fusion.dart';
import 'package:flutter/foundation.dart';
Expand All @@ -17,13 +19,15 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,

/// Set the app theme to use Material 3
theme: ThemeData(
useMaterial3: true,
),

/// Set the app home page to be the Test widget
home: const Test(title: 'Flutter Demo Home Page'),
home: const Test(title: 'Example'),
);
}
}
Expand Down Expand Up @@ -53,7 +57,11 @@ class _TestState extends State<Test> {
/// The [_generate] function to generate image data.
Future<Uint8List> _generate(String query) async {
/// Call the runAI method with the required parameters.
Uint8List image = await _ai.runAI(query, AIStyle.anime, Resolution.r1x1);
Uint8List image = await _ai.runAI(
query,
AIStyle.sovietCartoon,
Resolution.r1x1,
);
return image;
}

Expand All @@ -71,6 +79,7 @@ class _TestState extends State<Test> {
? MediaQuery.of(context).size.width
: MediaQuery.of(context).size.height / 2;
return Scaffold(
backgroundColor: Colors.grey.shade200,
appBar: AppBar(
title: Text(widget.title),
),
Expand All @@ -79,10 +88,25 @@ class _TestState extends State<Test> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
TextField(
controller: _queryController,
decoration: const InputDecoration(
hintText: 'Enter query text...',
Container(
width: double.infinity,
height: 50,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.white,
border: Border.all(
width: 0.5,
color: Colors.grey.shade300,
),
),
child: TextField(
controller: _queryController,
decoration: InputDecoration(
hintText: 'Enter query text...',
border: InputBorder.none,
contentPadding: EdgeInsets.only(left: 8),
),
),
),
Padding(
Expand All @@ -98,13 +122,18 @@ class _TestState extends State<Test> {
if (snapshot.connectionState ==
ConnectionState.waiting) {
/// While waiting for the image data, display a loading indicator.
return const CircularProgressIndicator();
return Center(
child: const CircularProgressIndicator(),
);
} else if (snapshot.hasError) {
/// If an error occurred while getting the image data, display an error message.
return Text('Error: ${snapshot.error}');
} else if (snapshot.hasData) {
/// If the image data is available, display the image using Image.memory().
return Image.memory(snapshot.data!);
return ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.memory(snapshot.data!),
);
} else {
/// If no data is available, display a placeholder or an empty container.
return Container();
Expand Down
22 changes: 15 additions & 7 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.1.1"
characters:
dependency: transitive
description:
Expand All @@ -44,10 +44,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.17.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -106,6 +106,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
material_color_utilities:
dependency: transitive
description:
Expand Down Expand Up @@ -139,10 +147,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.9.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -179,10 +187,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.5.1"
typed_data:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions lib/src/api/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class Run {
return 'KHOKHLOMA';
case AIStyle.christmas:
return 'CRISTMAS';
case AIStyle.sovietCartoon:
return 'SOVIETCARTOON';
default:
return 'DEFAULT';
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/data/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ enum AIStyle {
render3D, // 3D rendering style
/// Cartoon style
cartoon, // Cartoon
//Soviet cartoon
sovietCartoon,
/// Studio photo style
studioPhoto, // Studio photo style
/// Portrait photo style
Expand Down

0 comments on commit 7e66d3a

Please sign in to comment.