Skip to content
Open
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
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 29
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
28 changes: 14 additions & 14 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
>
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.9.0'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:7.4.1'
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 android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=false
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
26 changes: 13 additions & 13 deletions lib/comps/cigaratte.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import 'package:quitsmoke/static/htimes.dart';

class Cigaratte {
Cigaratte({
required this.startDate,
required this.pricePerCigaratte,
required this.dailyCigarattes,
this.lang,
}) : cigarattePerSecond = dailyCigarattes / (24 * 60 * 60.0),
moneyPerSecond = dailyCigarattes / (24 * 60 * 60.0) * pricePerCigaratte;

final DateTime startDate;
final double pricePerCigaratte;
final int dailyCigarattes;
final String lang;
final String? lang;

double cigarattePerSecond;
double moneyPerSecond;
double toUp = 0;

Cigaratte(
{this.startDate,
this.pricePerCigaratte,
this.dailyCigarattes,
this.lang}) {
cigarattePerSecond = dailyCigarattes / (24 * 60 * 60.0);
moneyPerSecond = cigarattePerSecond * pricePerCigaratte;
}
final double cigarattePerSecond;
final double moneyPerSecond;
final double toUp = 0;

Duration calculatePassedTime() {
DateTime now = DateTime.now();
Expand Down
51 changes: 23 additions & 28 deletions lib/comps/particle.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:quitsmoke/comps/particleSpawner.dart';

class ParticlePainter extends CustomPainter {
ParticlePainter({
required this.particleCount,
required this.particles,
}) : mPaint = new Paint(),
bgPaint = new Paint()..color = Color.fromARGB(120, 145, 132, 245),
super(repaint: particles);

final int particleCount;
int particleRadius = 3;
int sprayRadius = 100;

ParticleSpawner particles;
Rect _area;
Paint mPaint;
Paint bgPaint;

ParticlePainter({this.particleCount, this.particles})
: super(repaint: particles) {
mPaint = new Paint();
bgPaint = new Paint()..color = Color.fromARGB(120, 145, 132, 245);
}

@override
void paint(Canvas canvas, Size size) {
if (particles == null) return;

for (final particle in particles.particles) {
_drawParticle(particle, canvas);
}
Expand All @@ -34,14 +30,27 @@ class ParticlePainter extends CustomPainter {
}

_drawParticle(Particle particle, Canvas canvas) {
final random = Random();
canvas.drawOval(
Rect.fromLTWH(particle.x, particle.y, particle.r, particle.r),
Paint()..color = particle.color);
Rect.fromLTWH(particle.x, particle.y, particle.r, particle.r),
Paint()..color = particle.color,
);
}
}

class Particle {
Particle({
required double xval,
required double yval,
required double vvalX,
required double vvalY,
this.color = Colors.black,
double? avalX,
double? avalY,
}) : x = xval,
y = yval,
vX = vvalX,
vY = vvalY;

double vX;
double vY;

Expand All @@ -50,20 +59,6 @@ class Particle {
double r = 3;
final Color color;

Particle(
{double xval,
double yval,
double avalX,
double avalY,
double vvalX,
double vvalY,
this.color}) {
x = xval;
y = yval;
vX = vvalX;
vY = vvalY;
}

update() {
x += vX;
y += vY;
Expand Down
14 changes: 7 additions & 7 deletions lib/comps/particlePainer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ import 'package:quitsmoke/comps/particleSpawner.dart';

class ParticlePainterWidget extends StatefulWidget {
final Size widgetSize;
ParticlePainterWidget({Key key, this.widgetSize}) : super(key: key);

ParticlePainterWidget({Key? key, required this.widgetSize}) : super(key: key);

@override
_ParticlePainterWidgetState createState() => _ParticlePainterWidgetState();
}

class _ParticlePainterWidgetState extends State<ParticlePainterWidget> {
Timer _timer;
ValueNotifier<double> _time;
late Timer _timer;
late final ValueNotifier<double> _time;

ParticleSpawner particles;
late final ParticleSpawner particles;

@override
void initState() {
super.initState();

particles = new ParticleSpawner(size: widget.widgetSize);
particles.createParticles(3);
particles = ParticleSpawner(size: widget.widgetSize)..createParticles(3);
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using cascade notation to call createParticles immediately after construction couples initialization logic with object creation. Consider moving createParticles(3) to a separate line or creating a factory method for better readability and separation of concerns.

Suggested change
particles = ParticleSpawner(size: widget.widgetSize)..createParticles(3);
particles = ParticleSpawner(size: widget.widgetSize);
particles.createParticles(3);

Copilot uses AI. Check for mistakes.

_time = ValueNotifier(0);

// Setup timer.
final begin = DateTime.now();

_timer = Timer.periodic(
Duration(
microseconds: 1e6 ~/ 60, // 60 FPS
Expand Down
25 changes: 14 additions & 11 deletions lib/comps/particleSpawner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import 'package:flutter/material.dart';
import 'package:quitsmoke/comps/particle.dart';

class ParticleSpawner with ChangeNotifier {
List<Particle> particles = [];
double initialX;
double initialY;
ParticleSpawner({required this.size});

final Size size;
late double initialX;
late double initialY;
List<Particle> particles = [];
double degree = 0;
double sprayRadius = 70;
ParticleSpawner({this.size});

createParticles(int count) {
final random = Random();
initialX = size.width / 2;
Expand All @@ -37,13 +39,14 @@ class ParticleSpawner with ChangeNotifier {
}

updateParticles() {
for (var particle in particles) {
particle.update();
}
particles.removeWhere((element) =>
(initialX - element.x).abs() > sprayRadius ||
(initialY - element.y).abs() > sprayRadius ||
(element.vX.abs() < 0.1 && element.vY.abs() < 0.1));
for (var particle in particles) particle.update();

particles.removeWhere(
(element) =>
(initialX - element.x).abs() > sprayRadius ||
(initialY - element.y).abs() > sprayRadius ||
(element.vX.abs() < 0.1 && element.vY.abs() < 0.1),
);

notifyListeners();
}
Expand Down
13 changes: 6 additions & 7 deletions lib/comps/progress_painter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:math';
import 'dart:ui';

import 'package:flutter/material.dart';

class ProgressPainter extends CustomPainter {
Expand All @@ -9,11 +7,12 @@ class ProgressPainter extends CustomPainter {
final double completedPercentage;
final double circleWidth;

ProgressPainter(
{this.defaultCircleColor,
this.percentageCompletedCircleColor,
this.circleWidth,
this.completedPercentage});
ProgressPainter({
required this.defaultCircleColor,
required this.percentageCompletedCircleColor,
required this.circleWidth,
required this.completedPercentage,
});

getPaint(Color color) {
return Paint()
Expand Down
Loading