-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add settings page, import export feature, version bump
- Loading branch information
1 parent
b536786
commit ff3fb92
Showing
15 changed files
with
389 additions
and
187 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:emotic/data/emoticons_repository.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
part 'settings_state.dart'; | ||
|
||
class SettingsCubit extends Cubit<SettingsState> { | ||
final EmoticonsRepository emoticonsRepository; | ||
SettingsCubit({ | ||
required this.emoticonsRepository, | ||
}) : super(SettingsInitial()) { | ||
emit(SettingsLoading()); | ||
emit(SettingsLoaded()); | ||
} | ||
|
||
Future<void> clearAllData() async { | ||
emit(SettingsLoading()); | ||
await emoticonsRepository.clearAllData(); | ||
emit(SettingsLoaded(snackBarMessage: "Cleared data")); | ||
} | ||
|
||
Future<void> exportData() async { | ||
emit(SettingsLoading()); | ||
final result = await emoticonsRepository.exportToFile(); | ||
if (result.isError) { | ||
emit(SettingsLoaded( | ||
snackBarMessage: "Error exporting: ${result.asError!.error}", | ||
)); | ||
} else { | ||
emit(SettingsLoaded( | ||
snackBarMessage: "Export successful", | ||
)); | ||
} | ||
} | ||
|
||
Future<void> importData() async { | ||
emit(SettingsLoading()); | ||
final result = await emoticonsRepository.importFromFile(); | ||
if (result.isError) { | ||
emit(SettingsLoaded( | ||
snackBarMessage: "Error reading data: ${result.asError!.error}", | ||
)); | ||
} else { | ||
emit(SettingsLoaded( | ||
snackBarMessage: "Import successful", | ||
)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
part of 'settings_cubit.dart'; | ||
|
||
sealed class SettingsState {} | ||
|
||
class SettingsInitial extends SettingsState {} | ||
|
||
class SettingsLoading extends SettingsState {} | ||
|
||
class SettingsLoaded extends SettingsState with EquatableMixin { | ||
final String? snackBarMessage; | ||
SettingsLoaded({ | ||
this.snackBarMessage, | ||
}); | ||
@override | ||
List<Object?> get props => [ | ||
snackBarMessage, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.