Skip to content
Merged
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
630 changes: 308 additions & 322 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions app/lib/blocs/dialog_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class DialogState {

class DialogBloc extends Bloc<DialogEvent, DialogState> {
DialogBloc()
: super(
DialogState(
title: (context) => const Placeholder(),
onConfirm: (context) async => false,
),
) {
: super(
DialogState(
title: (context) => const Placeholder(),
onConfirm: (context) async => false,
),
) {
on<DialogAlertEvent>((event, emit) async {
emit(
DialogState(
Expand Down
45 changes: 6 additions & 39 deletions app/lib/blocs/tasks_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:stride/bridge/api/repository.dart';
import 'package:stride/bridge/third_party/stride_backend_git/known_hosts.dart';
import 'package:stride/bridge/third_party/stride_core/event.dart';
import 'package:stride/bridge/third_party/stride_core/task.dart';
import 'package:stride/routes/encryption_key_route.dart';
import 'package:uuid/uuid.dart';

@immutable
Expand All @@ -30,13 +29,9 @@ final class TaskRemoveEvent extends TaskEvent {
TaskRemoveEvent({required this.task});
}

final class TaskRemoveAllEvent extends TaskEvent {
final bool all;
TaskRemoveAllEvent({this.all = false});
}

final class TaskForcePushEvent extends TaskEvent {
TaskForcePushEvent();
final class TaskRemoveRepositoryEvent extends TaskEvent {
final UuidValue uuid;
TaskRemoveRepositoryEvent({required this.uuid});
}

final class TaskChangeStatusEvent extends TaskEvent {
Expand All @@ -60,10 +55,6 @@ final class TaskFilterEvent extends TaskEvent {
TaskFilterEvent({this.filter});
}

final class TaskCheckoutBranchEvent extends TaskEvent {
TaskCheckoutBranchEvent();
}

class TaskState {
final List<Task> tasks;
final bool syncing;
Expand Down Expand Up @@ -156,20 +147,8 @@ class TaskBloc extends Bloc<TaskEvent, TaskState> {
emit(TaskState(tasks: await _tasks()));
});

on<TaskRemoveAllEvent>((event, emit) async {
if (event.all) {
throw UnimplementedError();
} else {
// await repository()?.deleteDatabase();
// throw UnimplementedError();
}
// emit(TaskState(tasks: await _tasks()));
});

on<TaskForcePushEvent>((event, emit) async {
// await repository()?.push(force: true);
throw UnimplementedError();
// emit(TaskState(tasks: await _tasks()));
on<TaskRemoveRepositoryEvent>((event, emit) async {
await Repository.remove(uuid: event.uuid);
});

on<TaskChangeStatusEvent>((event, emit) async {
Expand Down Expand Up @@ -201,12 +180,6 @@ class TaskBloc extends Bloc<TaskEvent, TaskState> {
filter = event.filter;
emit(TaskState(tasks: await _tasks()));
});

on<TaskCheckoutBranchEvent>((event, emit) async {
// await repository()?.checkout();
throw UnimplementedError();
// emit(TaskState(tasks: await _tasks()));
});
}

Future<List<Task>> _tasks() async {
Expand Down Expand Up @@ -261,13 +234,7 @@ class TaskBloc extends Bloc<TaskEvent, TaskState> {
content: 'Are you sure the encryption key is correct?',
onConfirm: (context) async {
Navigator.pop(context);
await Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (context) => EncryptionKeyRoute(
repository: settingsBloc.settings.repositories.first,
),
),
);
// TODO: Send user to encryption key.
return true;
},
),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/bridge/api/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:stride/bridge/frb_generated.dart';
import 'package:stride/bridge/third_party/stride_backend_git/known_hosts.dart';

// These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `ErrorKind`, `ExportError`, `ImportError`, `SettingsError`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `source`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `source`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RustError>>
abstract class RustError implements RustOpaqueInterface {
Expand Down
54 changes: 53 additions & 1 deletion app/lib/bridge/api/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,33 @@ import 'package:stride/bridge/third_party/stride_core/task/annotation.dart';
import 'package:stride/bridge/third_party/stride_core/task/uda.dart';
import 'package:uuid/uuid.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `fmt`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `fmt`, `fmt`
// These functions are ignored (category: IgnoreBecauseExplicitAttribute): `database_mut`, `database`, `root_path`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<Repository>>
abstract class Repository implements RustOpaqueInterface {
Future<void> addBackend({required String name});

Future<List<Task>> allTasks({required Filter filter});

Future<BackendRecord?> backend({required UuidValue id});

Future<List<String>> backendNames();

Future<List<BackendRecord>> backends();

Future<void> deleteBackend({required UuidValue id});

Future<void> insertTask({required Task task});

static Repository open({required UuidValue uuid}) =>
RustLib.instance.api.crateApiRepositoryRepositoryOpen(uuid: uuid);

Future<Task?> purgeTaskById({required UuidValue id});

static Future<void> remove({required UuidValue uuid}) =>
RustLib.instance.api.crateApiRepositoryRepositoryRemove(uuid: uuid);

Future<void> sync_();

Future<Task?> taskById({required UuidValue id});
Expand All @@ -41,7 +54,46 @@ abstract class Repository implements RustOpaqueInterface {

Future<List<Task>> tasksByStatus({required Set<TaskStatus> status});

Future<void> toggleBackend({required UuidValue id});

Future<void> undo();

Future<void> updateBackend({required BackendRecord backend});

Future<void> updateTask({required Task task});
}

class BackendRecord {
final UuidValue id;
final String name;
final bool enabled;
final String schema;
final String config;

const BackendRecord({
required this.id,
required this.name,
required this.enabled,
required this.schema,
required this.config,
});

@override
int get hashCode =>
id.hashCode ^
name.hashCode ^
enabled.hashCode ^
schema.hashCode ^
config.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BackendRecord &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
enabled == other.enabled &&
schema == other.schema &&
config == other.config;
}
9 changes: 1 addition & 8 deletions app/lib/bridge/api/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
import 'package:stride/bridge/api/error.dart';
import 'package:stride/bridge/api/filter.dart';
import 'package:stride/bridge/frb_generated.dart';
import 'package:stride/bridge/third_party/stride_backend_git/encryption_key.dart';
import 'package:stride/bridge/third_party/stride_core/task.dart';
import 'package:uuid/uuid.dart';

part 'settings.freezed.dart';

// These functions are ignored because they are not marked as `pub`: `application_cache_path`, `application_document_path`, `application_log_path`, `application_support_path`, `default_author`, `default_branch_name`, `default_email`, `default_repository_name`, `default_theme_mode`, `ssh_key_path`
// These functions are ignored because they are not marked as `pub`: `application_cache_path`, `application_document_path`, `application_log_path`, `application_support_path`, `default_repository_name`, `default_theme_mode`, `ssh_key_path`
// These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `State`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`, `fmt`
// These functions are ignored (category: IgnoreBecauseOwnerTyShouldIgnore): `default`
Expand Down Expand Up @@ -98,12 +97,6 @@ sealed class RepositorySpecification with _$RepositorySpecification {
const factory RepositorySpecification({
required UuidValue uuid,
required String name,
required String origin,
required String author,
required String email,
required String branch,
UuidValue? sshKeyUuid,
EncryptionKey? encryption,
}) = _RepositorySpecification;
const RepositorySpecification._();
static Future<RepositorySpecification> default_() =>
Expand Down
58 changes: 20 additions & 38 deletions app/lib/bridge/api/settings.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading