Skip to content

Commit

Permalink
feat: import explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
borgoat committed Dec 21, 2024
1 parent 0c83f3d commit d4769fe
Show file tree
Hide file tree
Showing 14 changed files with 355 additions and 23 deletions.
34 changes: 34 additions & 0 deletions assets/content/ios.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
You'll have to export your WhatsApp chat and import it into the app to generate messages based on it.

**EVERYTHING IS DONE LOCALLY ON YOUR DEVICE** 🙃

## Open a chat in WhatsApp

![Open a Chat](resource:assets/images/ios_1.webp)

## Go to Chat Info

Tap on the chat name at the top to open the chat info.

![Go to Chat Info](resource:assets/images/ios_2.webp)

## Tap on Export Chat

Scroll down and tap on "Export Chat".

![Tap on Export Chat](resource:assets/images/ios_3.webp)

## Without Media

There's no need to include media files, so tap on "Without Media".

![Without Media](resource:assets/images/ios_4.webp)

## Select "Artificial Stupidity"

Select this app as the target for the exported chat.

Now wait a few seconds (or minutes, depending on the chat size)
for the app to process the chat.


Binary file added assets/images/ios_1.webp
Binary file not shown.
Binary file added assets/images/ios_2.webp
Binary file not shown.
Binary file added assets/images/ios_3.webp
Binary file not shown.
Binary file added assets/images/ios_4.webp
Binary file not shown.
22 changes: 20 additions & 2 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'dart:ui';

import 'package:artificialstupidity/app/bloc/app_bloc.dart';
import 'package:artificialstupidity/home/home.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';

class App extends StatelessWidget {
Expand Down Expand Up @@ -31,10 +34,25 @@ class AppView extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
final seedColor = Color.from(
alpha: 1, red: 0, green: 1, blue: 0, colorSpace: ColorSpace.displayP3);

ColorScheme lightColorScheme = ColorScheme.fromSeed(seedColor: seedColor);
ColorScheme darkColorScheme =
ColorScheme.fromSeed(brightness: Brightness.dark, seedColor: seedColor);

return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: HomePage(),
home: const HomePage(),
darkTheme: ThemeData.from(
colorScheme: darkColorScheme,
textTheme: GoogleFonts.cagliostroTextTheme(ThemeData.dark().textTheme),
),
theme: ThemeData.from(
colorScheme: lightColorScheme,
textTheme: GoogleFonts.cagliostroTextTheme(),
),
);
}
}
18 changes: 18 additions & 0 deletions lib/home/bloc/home_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ part 'home_state.dart';
class HomeBloc extends HydratedBloc<HomeEvent, HomeState> {
HomeBloc() : super(const HomeState.initial()) {
on<HomeGeneratedChainModel>(_onGeneratedMarkovChains);
on<HomeDeleteChainModel>(_onDeleteChainModel);
}

void _onGeneratedMarkovChains(
Expand All @@ -27,6 +28,23 @@ class HomeBloc extends HydratedBloc<HomeEvent, HomeState> {
}
}

void _onDeleteChainModel(
HomeDeleteChainModel event,
Emitter<HomeState> emit,
) {
if (state is HomeLoadedChainModels) {
final newState = (state as HomeLoadedChainModels)
.chainModels
.where((chainModel) => chainModel != event.chainModel)
.toList();
if (newState.isNotEmpty) {
emit(HomeState.loadedChainModels(chainModels: newState));
} else {
emit(const HomeState.initial());
}
}
}

@override
HomeState? fromJson(Map<String, dynamic> json) {
return HomeState.fromJson(json);
Expand Down
174 changes: 174 additions & 0 deletions lib/home/bloc/home_bloc.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,39 @@ mixin _$HomeEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ChainModel chainModel) generatedChainModel,
required TResult Function(ChainModel chainModel) deleteChainModel,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ChainModel chainModel)? generatedChainModel,
TResult? Function(ChainModel chainModel)? deleteChainModel,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ChainModel chainModel)? generatedChainModel,
TResult Function(ChainModel chainModel)? deleteChainModel,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(HomeGeneratedChainModel value)
generatedChainModel,
required TResult Function(HomeDeleteChainModel value) deleteChainModel,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(HomeGeneratedChainModel value)? generatedChainModel,
TResult? Function(HomeDeleteChainModel value)? deleteChainModel,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(HomeGeneratedChainModel value)? generatedChainModel,
TResult Function(HomeDeleteChainModel value)? deleteChainModel,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
Expand Down Expand Up @@ -192,6 +198,7 @@ class _$HomeGeneratedChainModelImpl
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ChainModel chainModel) generatedChainModel,
required TResult Function(ChainModel chainModel) deleteChainModel,
}) {
return generatedChainModel(chainModel);
}
Expand All @@ -200,6 +207,7 @@ class _$HomeGeneratedChainModelImpl
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ChainModel chainModel)? generatedChainModel,
TResult? Function(ChainModel chainModel)? deleteChainModel,
}) {
return generatedChainModel?.call(chainModel);
}
Expand All @@ -208,6 +216,7 @@ class _$HomeGeneratedChainModelImpl
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ChainModel chainModel)? generatedChainModel,
TResult Function(ChainModel chainModel)? deleteChainModel,
required TResult orElse(),
}) {
if (generatedChainModel != null) {
Expand All @@ -221,6 +230,7 @@ class _$HomeGeneratedChainModelImpl
TResult map<TResult extends Object?>({
required TResult Function(HomeGeneratedChainModel value)
generatedChainModel,
required TResult Function(HomeDeleteChainModel value) deleteChainModel,
}) {
return generatedChainModel(this);
}
Expand All @@ -229,6 +239,7 @@ class _$HomeGeneratedChainModelImpl
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(HomeGeneratedChainModel value)? generatedChainModel,
TResult? Function(HomeDeleteChainModel value)? deleteChainModel,
}) {
return generatedChainModel?.call(this);
}
Expand All @@ -237,6 +248,7 @@ class _$HomeGeneratedChainModelImpl
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(HomeGeneratedChainModel value)? generatedChainModel,
TResult Function(HomeDeleteChainModel value)? deleteChainModel,
required TResult orElse(),
}) {
if (generatedChainModel != null) {
Expand All @@ -261,6 +273,168 @@ abstract class HomeGeneratedChainModel implements HomeEvent {
get copyWith => throw _privateConstructorUsedError;
}

/// @nodoc
abstract class _$$HomeDeleteChainModelImplCopyWith<$Res>
implements $HomeEventCopyWith<$Res> {
factory _$$HomeDeleteChainModelImplCopyWith(_$HomeDeleteChainModelImpl value,
$Res Function(_$HomeDeleteChainModelImpl) then) =
__$$HomeDeleteChainModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({ChainModel chainModel});

@override
$ChainModelCopyWith<$Res> get chainModel;
}

/// @nodoc
class __$$HomeDeleteChainModelImplCopyWithImpl<$Res>
extends _$HomeEventCopyWithImpl<$Res, _$HomeDeleteChainModelImpl>
implements _$$HomeDeleteChainModelImplCopyWith<$Res> {
__$$HomeDeleteChainModelImplCopyWithImpl(_$HomeDeleteChainModelImpl _value,
$Res Function(_$HomeDeleteChainModelImpl) _then)
: super(_value, _then);

/// Create a copy of HomeEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? chainModel = null,
}) {
return _then(_$HomeDeleteChainModelImpl(
chainModel: null == chainModel
? _value.chainModel
: chainModel // ignore: cast_nullable_to_non_nullable
as ChainModel,
));
}
}

/// @nodoc
class _$HomeDeleteChainModelImpl
with DiagnosticableTreeMixin
implements HomeDeleteChainModel {
const _$HomeDeleteChainModelImpl({required this.chainModel});

@override
final ChainModel chainModel;

@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'HomeEvent.deleteChainModel(chainModel: $chainModel)';
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty('type', 'HomeEvent.deleteChainModel'))
..add(DiagnosticsProperty('chainModel', chainModel));
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$HomeDeleteChainModelImpl &&
(identical(other.chainModel, chainModel) ||
other.chainModel == chainModel));
}

@override
int get hashCode => Object.hash(runtimeType, chainModel);

/// Create a copy of HomeEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$HomeDeleteChainModelImplCopyWith<_$HomeDeleteChainModelImpl>
get copyWith =>
__$$HomeDeleteChainModelImplCopyWithImpl<_$HomeDeleteChainModelImpl>(
this, _$identity);

@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ChainModel chainModel) generatedChainModel,
required TResult Function(ChainModel chainModel) deleteChainModel,
}) {
return deleteChainModel(chainModel);
}

@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ChainModel chainModel)? generatedChainModel,
TResult? Function(ChainModel chainModel)? deleteChainModel,
}) {
return deleteChainModel?.call(chainModel);
}

@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ChainModel chainModel)? generatedChainModel,
TResult Function(ChainModel chainModel)? deleteChainModel,
required TResult orElse(),
}) {
if (deleteChainModel != null) {
return deleteChainModel(chainModel);
}
return orElse();
}

@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(HomeGeneratedChainModel value)
generatedChainModel,
required TResult Function(HomeDeleteChainModel value) deleteChainModel,
}) {
return deleteChainModel(this);
}

@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(HomeGeneratedChainModel value)? generatedChainModel,
TResult? Function(HomeDeleteChainModel value)? deleteChainModel,
}) {
return deleteChainModel?.call(this);
}

@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(HomeGeneratedChainModel value)? generatedChainModel,
TResult Function(HomeDeleteChainModel value)? deleteChainModel,
required TResult orElse(),
}) {
if (deleteChainModel != null) {
return deleteChainModel(this);
}
return orElse();
}
}

abstract class HomeDeleteChainModel implements HomeEvent {
const factory HomeDeleteChainModel({required final ChainModel chainModel}) =
_$HomeDeleteChainModelImpl;

@override
ChainModel get chainModel;

/// Create a copy of HomeEvent
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$HomeDeleteChainModelImplCopyWith<_$HomeDeleteChainModelImpl>
get copyWith => throw _privateConstructorUsedError;
}

HomeState _$HomeStateFromJson(Map<String, dynamic> json) {
switch (json['runtimeType']) {
case 'initial':
Expand Down
4 changes: 4 additions & 0 deletions lib/home/bloc/home_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ sealed class HomeEvent with _$HomeEvent {
const factory HomeEvent.generatedChainModel({
required ChainModel chainModel,
}) = HomeGeneratedChainModel;

const factory HomeEvent.deleteChainModel({
required ChainModel chainModel,
}) = HomeDeleteChainModel;
}
Loading

0 comments on commit d4769fe

Please sign in to comment.