Skip to content

Commit aaa1e34

Browse files
committed
Implement configurable backends in flutter
1 parent 9088046 commit aaa1e34

40 files changed

+2190
-1162
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/lib/blocs/tasks_bloc.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import 'package:stride/bridge/api/repository.dart';
1212
import 'package:stride/bridge/third_party/stride_backend_git/known_hosts.dart';
1313
import 'package:stride/bridge/third_party/stride_core/event.dart';
1414
import 'package:stride/bridge/third_party/stride_core/task.dart';
15-
import 'package:stride/routes/encryption_key_route.dart';
1615
import 'package:uuid/uuid.dart';
1716

1817
@immutable
@@ -261,13 +260,13 @@ class TaskBloc extends Bloc<TaskEvent, TaskState> {
261260
content: 'Are you sure the encryption key is correct?',
262261
onConfirm: (context) async {
263262
Navigator.pop(context);
264-
await Navigator.of(context).push<void>(
265-
MaterialPageRoute(
266-
builder: (context) => EncryptionKeyRoute(
267-
repository: settingsBloc.settings.repositories.first,
268-
),
269-
),
270-
);
263+
// await Navigator.of(context).push<void>(
264+
// MaterialPageRoute(
265+
// builder: (context) => EncryptionKeyRoute(
266+
// repository: settingsBloc.settings.repositories.first,
267+
// ),
268+
// ),
269+
// );
271270
return true;
272271
},
273272
),

app/lib/bridge/api/error.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'package:stride/bridge/frb_generated.dart';
1414
import 'package:stride/bridge/third_party/stride_backend_git/known_hosts.dart';
1515

1616
// 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`
17-
// 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`
17+
// 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`
1818

1919
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RustError>>
2020
abstract class RustError implements RustOpaqueInterface {

app/lib/bridge/api/repository.dart

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ import 'package:stride/bridge/third_party/stride_core/task/annotation.dart';
1919
import 'package:stride/bridge/third_party/stride_core/task/uda.dart';
2020
import 'package:uuid/uuid.dart';
2121

22-
// 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`
22+
// 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`
2323
// These functions are ignored (category: IgnoreBecauseExplicitAttribute): `database_mut`, `database`, `root_path`
2424

2525
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<Repository>>
2626
abstract class Repository implements RustOpaqueInterface {
27+
Future<void> addBackend({required String name});
28+
2729
Future<List<Task>> allTasks({required Filter filter});
2830

31+
Future<List<String>> backendNames();
32+
33+
Future<List<BackendRecord>> backends();
34+
2935
Future<void> insertTask({required Task task});
3036

3137
static Repository open({required UuidValue uuid}) =>
@@ -43,5 +49,35 @@ abstract class Repository implements RustOpaqueInterface {
4349

4450
Future<void> undo();
4551

52+
Future<void> updateBackend({required BackendRecord backend});
53+
4654
Future<void> updateTask({required Task task});
4755
}
56+
57+
class BackendRecord {
58+
final UuidValue id;
59+
final String name;
60+
final bool enabled;
61+
final String config;
62+
63+
const BackendRecord({
64+
required this.id,
65+
required this.name,
66+
required this.enabled,
67+
required this.config,
68+
});
69+
70+
@override
71+
int get hashCode =>
72+
id.hashCode ^ name.hashCode ^ enabled.hashCode ^ config.hashCode;
73+
74+
@override
75+
bool operator ==(Object other) =>
76+
identical(this, other) ||
77+
other is BackendRecord &&
78+
runtimeType == other.runtimeType &&
79+
id == other.id &&
80+
name == other.name &&
81+
enabled == other.enabled &&
82+
config == other.config;
83+
}

app/lib/bridge/api/settings.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
1414
import 'package:stride/bridge/api/error.dart';
1515
import 'package:stride/bridge/api/filter.dart';
1616
import 'package:stride/bridge/frb_generated.dart';
17-
import 'package:stride/bridge/third_party/stride_backend_git/encryption_key.dart';
1817
import 'package:stride/bridge/third_party/stride_core/task.dart';
1918
import 'package:uuid/uuid.dart';
2019

2120
part 'settings.freezed.dart';
2221

23-
// 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`
22+
// 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`
2423
// These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `State`
2524
// 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`
2625
// These functions are ignored (category: IgnoreBecauseOwnerTyShouldIgnore): `default`
@@ -98,12 +97,6 @@ sealed class RepositorySpecification with _$RepositorySpecification {
9897
const factory RepositorySpecification({
9998
required UuidValue uuid,
10099
required String name,
101-
required String origin,
102-
required String author,
103-
required String email,
104-
required String branch,
105-
UuidValue? sshKeyUuid,
106-
EncryptionKey? encryption,
107100
}) = _RepositorySpecification;
108101
const RepositorySpecification._();
109102
static Future<RepositorySpecification> default_() =>

app/lib/bridge/api/settings.freezed.dart

Lines changed: 20 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)