first commit

This commit is contained in:
2024-12-01 02:11:03 +07:00
commit 0266daf622
153 changed files with 9383 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import 'package:grpc/grpc.dart';
import 'generated/smm_core.pbgrpc.dart';
class AuthenticationInterceptor extends ClientInterceptor {
Future<void> _provider(Map<String, String> metadata, String uri) async {
metadata['Authorization'] = "Y3JhYjpjcmFi";
}
@override
ResponseFuture<R> interceptUnary<Q, R>(
ClientMethod<Q, R> method, Q request, CallOptions options, invoker) {
return super.interceptUnary(method, request,
options.mergedWith(CallOptions(providers: [_provider])), invoker);
}
}
class SmmCoreTerminalClient {
late final ClientChannel channel;
late final SmmCoreClient stub;
SmmCoreTerminalClient() {
channel = ClientChannel(
'0.0.0.0',
port: 8080,
options: ChannelOptions(credentials: ChannelCredentials.insecure()),
);
stub = SmmCoreClient(channel, interceptors: [AuthenticationInterceptor()]);
}
}
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
//
// Generated code. Do not modify.
// source: smm_core.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
+379
View File
@@ -0,0 +1,379 @@
//
// Generated code. Do not modify.
// source: smm_core.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
import 'dart:async' as $async;
import 'dart:core' as $core;
import 'package:grpc/service_api.dart' as $grpc;
import 'package:protobuf/protobuf.dart' as $pb;
import 'smm_core.pb.dart' as $0;
export 'smm_core.pb.dart';
@$pb.GrpcServiceName('crabs.smm_core.SmmCore')
class SmmCoreClient extends $grpc.Client {
static final _$ping = $grpc.ClientMethod<$0.PingReq, $0.PingRsp>(
'/crabs.smm_core.SmmCore/Ping',
($0.PingReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.PingRsp.fromBuffer(value));
static final _$login = $grpc.ClientMethod<$0.LoginReq, $0.User>(
'/crabs.smm_core.SmmCore/Login',
($0.LoginReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.User.fromBuffer(value));
static final _$addBudget = $grpc.ClientMethod<$0.AddBudgetReq, $0.Budget>(
'/crabs.smm_core.SmmCore/AddBudget',
($0.AddBudgetReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Budget.fromBuffer(value));
static final _$updateBudget = $grpc.ClientMethod<$0.UpdateBudgetReq, $0.Budget>(
'/crabs.smm_core.SmmCore/UpdateBudget',
($0.UpdateBudgetReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Budget.fromBuffer(value));
static final _$getBudgets = $grpc.ClientMethod<$0.GetBudgetsReq, $0.Budgets>(
'/crabs.smm_core.SmmCore/GetBudgets',
($0.GetBudgetsReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Budgets.fromBuffer(value));
static final _$deleteBudget = $grpc.ClientMethod<$0.DeleteBudgetReq, $0.Budget>(
'/crabs.smm_core.SmmCore/DeleteBudget',
($0.DeleteBudgetReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Budget.fromBuffer(value));
static final _$addUserToBudget = $grpc.ClientMethod<$0.AddUserToBudgetReq, $0.OK>(
'/crabs.smm_core.SmmCore/AddUserToBudget',
($0.AddUserToBudgetReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.OK.fromBuffer(value));
static final _$getBudgetUsers = $grpc.ClientMethod<$0.GetBudgetUsersReq, $0.Users>(
'/crabs.smm_core.SmmCore/GetBudgetUsers',
($0.GetBudgetUsersReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Users.fromBuffer(value));
static final _$removeUserFromBudget = $grpc.ClientMethod<$0.RemoveUserFromBudgetReq, $0.Budget>(
'/crabs.smm_core.SmmCore/RemoveUserFromBudget',
($0.RemoveUserFromBudgetReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Budget.fromBuffer(value));
static final _$getBudgetCategories = $grpc.ClientMethod<$0.GetBudgetCategoriesReq, $0.Categories>(
'/crabs.smm_core.SmmCore/GetBudgetCategories',
($0.GetBudgetCategoriesReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Categories.fromBuffer(value));
static final _$addCategory = $grpc.ClientMethod<$0.AddCategoryReq, $0.Category>(
'/crabs.smm_core.SmmCore/AddCategory',
($0.AddCategoryReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Category.fromBuffer(value));
static final _$updateCategory = $grpc.ClientMethod<$0.UpdateCategoryReq, $0.Category>(
'/crabs.smm_core.SmmCore/UpdateCategory',
($0.UpdateCategoryReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Category.fromBuffer(value));
static final _$deleteCategories = $grpc.ClientMethod<$0.DeleteCategoriesReq, $0.Category>(
'/crabs.smm_core.SmmCore/DeleteCategories',
($0.DeleteCategoriesReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Category.fromBuffer(value));
static final _$addWaste = $grpc.ClientMethod<$0.AddWasteReq, $0.Waste>(
'/crabs.smm_core.SmmCore/AddWaste',
($0.AddWasteReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Waste.fromBuffer(value));
static final _$addWasteByText = $grpc.ClientMethod<$0.AddWasteTextReq, $0.Waste>(
'/crabs.smm_core.SmmCore/AddWasteByText',
($0.AddWasteTextReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Waste.fromBuffer(value));
static final _$deleteWaste = $grpc.ClientMethod<$0.DeleteWasteReq, $0.Waste>(
'/crabs.smm_core.SmmCore/DeleteWaste',
($0.DeleteWasteReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.Waste.fromBuffer(value));
static final _$getCategoriesStat = $grpc.ClientMethod<$0.GetCategoriesStatReq, $0.CategoriesStat>(
'/crabs.smm_core.SmmCore/GetCategoriesStat',
($0.GetCategoriesStatReq value) => value.writeToBuffer(),
($core.List<$core.int> value) => $0.CategoriesStat.fromBuffer(value));
SmmCoreClient($grpc.ClientChannel channel,
{$grpc.CallOptions? options,
$core.Iterable<$grpc.ClientInterceptor>? interceptors})
: super(channel, options: options,
interceptors: interceptors);
$grpc.ResponseFuture<$0.PingRsp> ping($0.PingReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$ping, request, options: options);
}
$grpc.ResponseFuture<$0.User> login($0.LoginReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$login, request, options: options);
}
$grpc.ResponseFuture<$0.Budget> addBudget($0.AddBudgetReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$addBudget, request, options: options);
}
$grpc.ResponseFuture<$0.Budget> updateBudget($0.UpdateBudgetReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$updateBudget, request, options: options);
}
$grpc.ResponseFuture<$0.Budgets> getBudgets($0.GetBudgetsReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$getBudgets, request, options: options);
}
$grpc.ResponseFuture<$0.Budget> deleteBudget($0.DeleteBudgetReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$deleteBudget, request, options: options);
}
$grpc.ResponseFuture<$0.OK> addUserToBudget($0.AddUserToBudgetReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$addUserToBudget, request, options: options);
}
$grpc.ResponseFuture<$0.Users> getBudgetUsers($0.GetBudgetUsersReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$getBudgetUsers, request, options: options);
}
$grpc.ResponseFuture<$0.Budget> removeUserFromBudget($0.RemoveUserFromBudgetReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$removeUserFromBudget, request, options: options);
}
$grpc.ResponseFuture<$0.Categories> getBudgetCategories($0.GetBudgetCategoriesReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$getBudgetCategories, request, options: options);
}
$grpc.ResponseFuture<$0.Category> addCategory($0.AddCategoryReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$addCategory, request, options: options);
}
$grpc.ResponseFuture<$0.Category> updateCategory($0.UpdateCategoryReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$updateCategory, request, options: options);
}
$grpc.ResponseFuture<$0.Category> deleteCategories($0.DeleteCategoriesReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$deleteCategories, request, options: options);
}
$grpc.ResponseFuture<$0.Waste> addWaste($0.AddWasteReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$addWaste, request, options: options);
}
$grpc.ResponseFuture<$0.Waste> addWasteByText($0.AddWasteTextReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$addWasteByText, request, options: options);
}
$grpc.ResponseFuture<$0.Waste> deleteWaste($0.DeleteWasteReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$deleteWaste, request, options: options);
}
$grpc.ResponseFuture<$0.CategoriesStat> getCategoriesStat($0.GetCategoriesStatReq request, {$grpc.CallOptions? options}) {
return $createUnaryCall(_$getCategoriesStat, request, options: options);
}
}
@$pb.GrpcServiceName('crabs.smm_core.SmmCore')
abstract class SmmCoreServiceBase extends $grpc.Service {
$core.String get $name => 'crabs.smm_core.SmmCore';
SmmCoreServiceBase() {
$addMethod($grpc.ServiceMethod<$0.PingReq, $0.PingRsp>(
'Ping',
ping_Pre,
false,
false,
($core.List<$core.int> value) => $0.PingReq.fromBuffer(value),
($0.PingRsp value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.LoginReq, $0.User>(
'Login',
login_Pre,
false,
false,
($core.List<$core.int> value) => $0.LoginReq.fromBuffer(value),
($0.User value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.AddBudgetReq, $0.Budget>(
'AddBudget',
addBudget_Pre,
false,
false,
($core.List<$core.int> value) => $0.AddBudgetReq.fromBuffer(value),
($0.Budget value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.UpdateBudgetReq, $0.Budget>(
'UpdateBudget',
updateBudget_Pre,
false,
false,
($core.List<$core.int> value) => $0.UpdateBudgetReq.fromBuffer(value),
($0.Budget value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.GetBudgetsReq, $0.Budgets>(
'GetBudgets',
getBudgets_Pre,
false,
false,
($core.List<$core.int> value) => $0.GetBudgetsReq.fromBuffer(value),
($0.Budgets value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.DeleteBudgetReq, $0.Budget>(
'DeleteBudget',
deleteBudget_Pre,
false,
false,
($core.List<$core.int> value) => $0.DeleteBudgetReq.fromBuffer(value),
($0.Budget value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.AddUserToBudgetReq, $0.OK>(
'AddUserToBudget',
addUserToBudget_Pre,
false,
false,
($core.List<$core.int> value) => $0.AddUserToBudgetReq.fromBuffer(value),
($0.OK value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.GetBudgetUsersReq, $0.Users>(
'GetBudgetUsers',
getBudgetUsers_Pre,
false,
false,
($core.List<$core.int> value) => $0.GetBudgetUsersReq.fromBuffer(value),
($0.Users value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.RemoveUserFromBudgetReq, $0.Budget>(
'RemoveUserFromBudget',
removeUserFromBudget_Pre,
false,
false,
($core.List<$core.int> value) => $0.RemoveUserFromBudgetReq.fromBuffer(value),
($0.Budget value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.GetBudgetCategoriesReq, $0.Categories>(
'GetBudgetCategories',
getBudgetCategories_Pre,
false,
false,
($core.List<$core.int> value) => $0.GetBudgetCategoriesReq.fromBuffer(value),
($0.Categories value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.AddCategoryReq, $0.Category>(
'AddCategory',
addCategory_Pre,
false,
false,
($core.List<$core.int> value) => $0.AddCategoryReq.fromBuffer(value),
($0.Category value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.UpdateCategoryReq, $0.Category>(
'UpdateCategory',
updateCategory_Pre,
false,
false,
($core.List<$core.int> value) => $0.UpdateCategoryReq.fromBuffer(value),
($0.Category value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.DeleteCategoriesReq, $0.Category>(
'DeleteCategories',
deleteCategories_Pre,
false,
false,
($core.List<$core.int> value) => $0.DeleteCategoriesReq.fromBuffer(value),
($0.Category value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.AddWasteReq, $0.Waste>(
'AddWaste',
addWaste_Pre,
false,
false,
($core.List<$core.int> value) => $0.AddWasteReq.fromBuffer(value),
($0.Waste value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.AddWasteTextReq, $0.Waste>(
'AddWasteByText',
addWasteByText_Pre,
false,
false,
($core.List<$core.int> value) => $0.AddWasteTextReq.fromBuffer(value),
($0.Waste value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.DeleteWasteReq, $0.Waste>(
'DeleteWaste',
deleteWaste_Pre,
false,
false,
($core.List<$core.int> value) => $0.DeleteWasteReq.fromBuffer(value),
($0.Waste value) => value.writeToBuffer()));
$addMethod($grpc.ServiceMethod<$0.GetCategoriesStatReq, $0.CategoriesStat>(
'GetCategoriesStat',
getCategoriesStat_Pre,
false,
false,
($core.List<$core.int> value) => $0.GetCategoriesStatReq.fromBuffer(value),
($0.CategoriesStat value) => value.writeToBuffer()));
}
$async.Future<$0.PingRsp> ping_Pre($grpc.ServiceCall call, $async.Future<$0.PingReq> request) async {
return ping(call, await request);
}
$async.Future<$0.User> login_Pre($grpc.ServiceCall call, $async.Future<$0.LoginReq> request) async {
return login(call, await request);
}
$async.Future<$0.Budget> addBudget_Pre($grpc.ServiceCall call, $async.Future<$0.AddBudgetReq> request) async {
return addBudget(call, await request);
}
$async.Future<$0.Budget> updateBudget_Pre($grpc.ServiceCall call, $async.Future<$0.UpdateBudgetReq> request) async {
return updateBudget(call, await request);
}
$async.Future<$0.Budgets> getBudgets_Pre($grpc.ServiceCall call, $async.Future<$0.GetBudgetsReq> request) async {
return getBudgets(call, await request);
}
$async.Future<$0.Budget> deleteBudget_Pre($grpc.ServiceCall call, $async.Future<$0.DeleteBudgetReq> request) async {
return deleteBudget(call, await request);
}
$async.Future<$0.OK> addUserToBudget_Pre($grpc.ServiceCall call, $async.Future<$0.AddUserToBudgetReq> request) async {
return addUserToBudget(call, await request);
}
$async.Future<$0.Users> getBudgetUsers_Pre($grpc.ServiceCall call, $async.Future<$0.GetBudgetUsersReq> request) async {
return getBudgetUsers(call, await request);
}
$async.Future<$0.Budget> removeUserFromBudget_Pre($grpc.ServiceCall call, $async.Future<$0.RemoveUserFromBudgetReq> request) async {
return removeUserFromBudget(call, await request);
}
$async.Future<$0.Categories> getBudgetCategories_Pre($grpc.ServiceCall call, $async.Future<$0.GetBudgetCategoriesReq> request) async {
return getBudgetCategories(call, await request);
}
$async.Future<$0.Category> addCategory_Pre($grpc.ServiceCall call, $async.Future<$0.AddCategoryReq> request) async {
return addCategory(call, await request);
}
$async.Future<$0.Category> updateCategory_Pre($grpc.ServiceCall call, $async.Future<$0.UpdateCategoryReq> request) async {
return updateCategory(call, await request);
}
$async.Future<$0.Category> deleteCategories_Pre($grpc.ServiceCall call, $async.Future<$0.DeleteCategoriesReq> request) async {
return deleteCategories(call, await request);
}
$async.Future<$0.Waste> addWaste_Pre($grpc.ServiceCall call, $async.Future<$0.AddWasteReq> request) async {
return addWaste(call, await request);
}
$async.Future<$0.Waste> addWasteByText_Pre($grpc.ServiceCall call, $async.Future<$0.AddWasteTextReq> request) async {
return addWasteByText(call, await request);
}
$async.Future<$0.Waste> deleteWaste_Pre($grpc.ServiceCall call, $async.Future<$0.DeleteWasteReq> request) async {
return deleteWaste(call, await request);
}
$async.Future<$0.CategoriesStat> getCategoriesStat_Pre($grpc.ServiceCall call, $async.Future<$0.GetCategoriesStatReq> request) async {
return getCategoriesStat(call, await request);
}
$async.Future<$0.PingRsp> ping($grpc.ServiceCall call, $0.PingReq request);
$async.Future<$0.User> login($grpc.ServiceCall call, $0.LoginReq request);
$async.Future<$0.Budget> addBudget($grpc.ServiceCall call, $0.AddBudgetReq request);
$async.Future<$0.Budget> updateBudget($grpc.ServiceCall call, $0.UpdateBudgetReq request);
$async.Future<$0.Budgets> getBudgets($grpc.ServiceCall call, $0.GetBudgetsReq request);
$async.Future<$0.Budget> deleteBudget($grpc.ServiceCall call, $0.DeleteBudgetReq request);
$async.Future<$0.OK> addUserToBudget($grpc.ServiceCall call, $0.AddUserToBudgetReq request);
$async.Future<$0.Users> getBudgetUsers($grpc.ServiceCall call, $0.GetBudgetUsersReq request);
$async.Future<$0.Budget> removeUserFromBudget($grpc.ServiceCall call, $0.RemoveUserFromBudgetReq request);
$async.Future<$0.Categories> getBudgetCategories($grpc.ServiceCall call, $0.GetBudgetCategoriesReq request);
$async.Future<$0.Category> addCategory($grpc.ServiceCall call, $0.AddCategoryReq request);
$async.Future<$0.Category> updateCategory($grpc.ServiceCall call, $0.UpdateCategoryReq request);
$async.Future<$0.Category> deleteCategories($grpc.ServiceCall call, $0.DeleteCategoriesReq request);
$async.Future<$0.Waste> addWaste($grpc.ServiceCall call, $0.AddWasteReq request);
$async.Future<$0.Waste> addWasteByText($grpc.ServiceCall call, $0.AddWasteTextReq request);
$async.Future<$0.Waste> deleteWaste($grpc.ServiceCall call, $0.DeleteWasteReq request);
$async.Future<$0.CategoriesStat> getCategoriesStat($grpc.ServiceCall call, $0.GetCategoriesStatReq request);
}
+410
View File
@@ -0,0 +1,410 @@
//
// Generated code. Do not modify.
// source: smm_core.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
import 'dart:convert' as $convert;
import 'dart:core' as $core;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use pingReqDescriptor instead')
const PingReq$json = {
'1': 'PingReq',
};
/// Descriptor for `PingReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List pingReqDescriptor = $convert.base64Decode(
'CgdQaW5nUmVx');
@$core.Deprecated('Use pingRspDescriptor instead')
const PingRsp$json = {
'1': 'PingRsp',
};
/// Descriptor for `PingRsp`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List pingRspDescriptor = $convert.base64Decode(
'CgdQaW5nUnNw');
@$core.Deprecated('Use oKDescriptor instead')
const OK$json = {
'1': 'OK',
};
/// Descriptor for `OK`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List oKDescriptor = $convert.base64Decode(
'CgJPSw==');
@$core.Deprecated('Use addUserReqDescriptor instead')
const AddUserReq$json = {
'1': 'AddUserReq',
'2': [
{'1': 'username', '3': 1, '4': 1, '5': 9, '10': 'username'},
{'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'},
],
};
/// Descriptor for `AddUserReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List addUserReqDescriptor = $convert.base64Decode(
'CgpBZGRVc2VyUmVxEhoKCHVzZXJuYW1lGAEgASgJUgh1c2VybmFtZRIaCghwYXNzd29yZBgCIA'
'EoCVIIcGFzc3dvcmQ=');
@$core.Deprecated('Use userDescriptor instead')
const User$json = {
'1': 'User',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
{'1': 'username', '3': 2, '4': 1, '5': 9, '10': 'username'},
],
};
/// Descriptor for `User`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List userDescriptor = $convert.base64Decode(
'CgRVc2VyEg4KAmlkGAEgASgFUgJpZBIaCgh1c2VybmFtZRgCIAEoCVIIdXNlcm5hbWU=');
@$core.Deprecated('Use loginReqDescriptor instead')
const LoginReq$json = {
'1': 'LoginReq',
'2': [
{'1': 'username', '3': 1, '4': 1, '5': 9, '10': 'username'},
{'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'},
],
};
/// Descriptor for `LoginReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List loginReqDescriptor = $convert.base64Decode(
'CghMb2dpblJlcRIaCgh1c2VybmFtZRgBIAEoCVIIdXNlcm5hbWUSGgoIcGFzc3dvcmQYAiABKA'
'lSCHBhc3N3b3Jk');
@$core.Deprecated('Use addBudgetReqDescriptor instead')
const AddBudgetReq$json = {
'1': 'AddBudgetReq',
'2': [
{'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'},
{'1': 'start_day', '3': 2, '4': 1, '5': 5, '10': 'startDay'},
{'1': 'monthly_limit', '3': 3, '4': 1, '5': 5, '10': 'monthlyLimit'},
],
};
/// Descriptor for `AddBudgetReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List addBudgetReqDescriptor = $convert.base64Decode(
'CgxBZGRCdWRnZXRSZXESEgoEbmFtZRgBIAEoCVIEbmFtZRIbCglzdGFydF9kYXkYAiABKAVSCH'
'N0YXJ0RGF5EiMKDW1vbnRobHlfbGltaXQYAyABKAVSDG1vbnRobHlMaW1pdA==');
@$core.Deprecated('Use budgetDescriptor instead')
const Budget$json = {
'1': 'Budget',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
{'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
{'1': 'start_day', '3': 3, '4': 1, '5': 5, '10': 'startDay'},
{'1': 'monthly_limit', '3': 4, '4': 1, '5': 5, '10': 'monthlyLimit'},
{'1': 'categories', '3': 5, '4': 3, '5': 11, '6': '.crabs.smm_core.Category', '10': 'categories'},
],
};
/// Descriptor for `Budget`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List budgetDescriptor = $convert.base64Decode(
'CgZCdWRnZXQSDgoCaWQYASABKAVSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSGwoJc3RhcnRfZG'
'F5GAMgASgFUghzdGFydERheRIjCg1tb250aGx5X2xpbWl0GAQgASgFUgxtb250aGx5TGltaXQS'
'OAoKY2F0ZWdvcmllcxgFIAMoCzIYLmNyYWJzLnNtbV9jb3JlLkNhdGVnb3J5UgpjYXRlZ29yaW'
'Vz');
@$core.Deprecated('Use updateBudgetReqDescriptor instead')
const UpdateBudgetReq$json = {
'1': 'UpdateBudgetReq',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
{'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
{'1': 'start_day', '3': 3, '4': 1, '5': 5, '10': 'startDay'},
{'1': 'monthly_limit', '3': 4, '4': 1, '5': 5, '10': 'monthlyLimit'},
],
};
/// Descriptor for `UpdateBudgetReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List updateBudgetReqDescriptor = $convert.base64Decode(
'Cg9VcGRhdGVCdWRnZXRSZXESDgoCaWQYASABKAVSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSGw'
'oJc3RhcnRfZGF5GAMgASgFUghzdGFydERheRIjCg1tb250aGx5X2xpbWl0GAQgASgFUgxtb250'
'aGx5TGltaXQ=');
@$core.Deprecated('Use getBudgetsReqDescriptor instead')
const GetBudgetsReq$json = {
'1': 'GetBudgetsReq',
};
/// Descriptor for `GetBudgetsReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getBudgetsReqDescriptor = $convert.base64Decode(
'Cg1HZXRCdWRnZXRzUmVx');
@$core.Deprecated('Use budgetsDescriptor instead')
const Budgets$json = {
'1': 'Budgets',
'2': [
{'1': 'budgets', '3': 1, '4': 3, '5': 11, '6': '.crabs.smm_core.Budget', '10': 'budgets'},
],
};
/// Descriptor for `Budgets`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List budgetsDescriptor = $convert.base64Decode(
'CgdCdWRnZXRzEjAKB2J1ZGdldHMYASADKAsyFi5jcmFicy5zbW1fY29yZS5CdWRnZXRSB2J1ZG'
'dldHM=');
@$core.Deprecated('Use deleteBudgetReqDescriptor instead')
const DeleteBudgetReq$json = {
'1': 'DeleteBudgetReq',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
],
};
/// Descriptor for `DeleteBudgetReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List deleteBudgetReqDescriptor = $convert.base64Decode(
'Cg9EZWxldGVCdWRnZXRSZXESDgoCaWQYASABKAVSAmlk');
@$core.Deprecated('Use addUserToBudgetReqDescriptor instead')
const AddUserToBudgetReq$json = {
'1': 'AddUserToBudgetReq',
'2': [
{'1': 'user_id', '3': 1, '4': 1, '5': 5, '10': 'userId'},
{'1': 'budget_id', '3': 2, '4': 1, '5': 5, '10': 'budgetId'},
],
};
/// Descriptor for `AddUserToBudgetReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List addUserToBudgetReqDescriptor = $convert.base64Decode(
'ChJBZGRVc2VyVG9CdWRnZXRSZXESFwoHdXNlcl9pZBgBIAEoBVIGdXNlcklkEhsKCWJ1ZGdldF'
'9pZBgCIAEoBVIIYnVkZ2V0SWQ=');
@$core.Deprecated('Use getBudgetUsersReqDescriptor instead')
const GetBudgetUsersReq$json = {
'1': 'GetBudgetUsersReq',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
],
};
/// Descriptor for `GetBudgetUsersReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getBudgetUsersReqDescriptor = $convert.base64Decode(
'ChFHZXRCdWRnZXRVc2Vyc1JlcRIOCgJpZBgBIAEoBVICaWQ=');
@$core.Deprecated('Use usersDescriptor instead')
const Users$json = {
'1': 'Users',
'2': [
{'1': 'users', '3': 1, '4': 3, '5': 11, '6': '.crabs.smm_core.User', '10': 'users'},
],
};
/// Descriptor for `Users`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List usersDescriptor = $convert.base64Decode(
'CgVVc2VycxIqCgV1c2VycxgBIAMoCzIULmNyYWJzLnNtbV9jb3JlLlVzZXJSBXVzZXJz');
@$core.Deprecated('Use removeUserFromBudgetReqDescriptor instead')
const RemoveUserFromBudgetReq$json = {
'1': 'RemoveUserFromBudgetReq',
'2': [
{'1': 'user_id', '3': 1, '4': 1, '5': 5, '10': 'userId'},
{'1': 'budget_id', '3': 2, '4': 1, '5': 5, '10': 'budgetId'},
],
};
/// Descriptor for `RemoveUserFromBudgetReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List removeUserFromBudgetReqDescriptor = $convert.base64Decode(
'ChdSZW1vdmVVc2VyRnJvbUJ1ZGdldFJlcRIXCgd1c2VyX2lkGAEgASgFUgZ1c2VySWQSGwoJYn'
'VkZ2V0X2lkGAIgASgFUghidWRnZXRJZA==');
@$core.Deprecated('Use getBudgetCategoriesReqDescriptor instead')
const GetBudgetCategoriesReq$json = {
'1': 'GetBudgetCategoriesReq',
'2': [
{'1': 'budget_id', '3': 2, '4': 1, '5': 5, '10': 'budgetId'},
],
};
/// Descriptor for `GetBudgetCategoriesReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getBudgetCategoriesReqDescriptor = $convert.base64Decode(
'ChZHZXRCdWRnZXRDYXRlZ29yaWVzUmVxEhsKCWJ1ZGdldF9pZBgCIAEoBVIIYnVkZ2V0SWQ=');
@$core.Deprecated('Use addCategoryReqDescriptor instead')
const AddCategoryReq$json = {
'1': 'AddCategoryReq',
'2': [
{'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'},
{'1': 'budget_id', '3': 2, '4': 1, '5': 5, '10': 'budgetId'},
{'1': 'favorite', '3': 3, '4': 1, '5': 8, '10': 'favorite'},
{'1': 'monthly_limit', '3': 4, '4': 1, '5': 5, '10': 'monthlyLimit'},
],
};
/// Descriptor for `AddCategoryReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List addCategoryReqDescriptor = $convert.base64Decode(
'Cg5BZGRDYXRlZ29yeVJlcRISCgRuYW1lGAEgASgJUgRuYW1lEhsKCWJ1ZGdldF9pZBgCIAEoBV'
'IIYnVkZ2V0SWQSGgoIZmF2b3JpdGUYAyABKAhSCGZhdm9yaXRlEiMKDW1vbnRobHlfbGltaXQY'
'BCABKAVSDG1vbnRobHlMaW1pdA==');
@$core.Deprecated('Use categoryDescriptor instead')
const Category$json = {
'1': 'Category',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
{'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
{'1': 'budget_id', '3': 3, '4': 1, '5': 5, '10': 'budgetId'},
{'1': 'favorite', '3': 4, '4': 1, '5': 8, '10': 'favorite'},
{'1': 'monthly_limit', '3': 5, '4': 1, '5': 5, '10': 'monthlyLimit'},
],
};
/// Descriptor for `Category`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List categoryDescriptor = $convert.base64Decode(
'CghDYXRlZ29yeRIOCgJpZBgBIAEoBVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZRIbCglidWRnZX'
'RfaWQYAyABKAVSCGJ1ZGdldElkEhoKCGZhdm9yaXRlGAQgASgIUghmYXZvcml0ZRIjCg1tb250'
'aGx5X2xpbWl0GAUgASgFUgxtb250aGx5TGltaXQ=');
@$core.Deprecated('Use updateCategoryReqDescriptor instead')
const UpdateCategoryReq$json = {
'1': 'UpdateCategoryReq',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
{'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
{'1': 'favorite', '3': 3, '4': 1, '5': 8, '10': 'favorite'},
{'1': 'monthly_limit', '3': 4, '4': 1, '5': 5, '10': 'monthlyLimit'},
],
};
/// Descriptor for `UpdateCategoryReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List updateCategoryReqDescriptor = $convert.base64Decode(
'ChFVcGRhdGVDYXRlZ29yeVJlcRIOCgJpZBgBIAEoBVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZR'
'IaCghmYXZvcml0ZRgDIAEoCFIIZmF2b3JpdGUSIwoNbW9udGhseV9saW1pdBgEIAEoBVIMbW9u'
'dGhseUxpbWl0');
@$core.Deprecated('Use categoriesDescriptor instead')
const Categories$json = {
'1': 'Categories',
'2': [
{'1': 'categories', '3': 1, '4': 3, '5': 11, '6': '.crabs.smm_core.Category', '10': 'categories'},
],
};
/// Descriptor for `Categories`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List categoriesDescriptor = $convert.base64Decode(
'CgpDYXRlZ29yaWVzEjgKCmNhdGVnb3JpZXMYASADKAsyGC5jcmFicy5zbW1fY29yZS5DYXRlZ2'
'9yeVIKY2F0ZWdvcmllcw==');
@$core.Deprecated('Use deleteCategoriesReqDescriptor instead')
const DeleteCategoriesReq$json = {
'1': 'DeleteCategoriesReq',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
],
};
/// Descriptor for `DeleteCategoriesReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List deleteCategoriesReqDescriptor = $convert.base64Decode(
'ChNEZWxldGVDYXRlZ29yaWVzUmVxEg4KAmlkGAEgASgFUgJpZA==');
@$core.Deprecated('Use addWasteReqDescriptor instead')
const AddWasteReq$json = {
'1': 'AddWasteReq',
'2': [
{'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'},
{'1': 'price', '3': 2, '4': 1, '5': 5, '10': 'price'},
{'1': 'amount', '3': 3, '4': 1, '5': 2, '10': 'amount'},
{'1': 'category_id', '3': 4, '4': 1, '5': 5, '10': 'categoryId'},
{'1': 'budget_id', '3': 5, '4': 1, '5': 5, '10': 'budgetId'},
],
};
/// Descriptor for `AddWasteReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List addWasteReqDescriptor = $convert.base64Decode(
'CgtBZGRXYXN0ZVJlcRISCgRuYW1lGAEgASgJUgRuYW1lEhQKBXByaWNlGAIgASgFUgVwcmljZR'
'IWCgZhbW91bnQYAyABKAJSBmFtb3VudBIfCgtjYXRlZ29yeV9pZBgEIAEoBVIKY2F0ZWdvcnlJ'
'ZBIbCglidWRnZXRfaWQYBSABKAVSCGJ1ZGdldElk');
@$core.Deprecated('Use addWasteTextReqDescriptor instead')
const AddWasteTextReq$json = {
'1': 'AddWasteTextReq',
'2': [
{'1': 'text', '3': 1, '4': 1, '5': 9, '10': 'text'},
{'1': 'category_id', '3': 2, '4': 1, '5': 5, '10': 'categoryId'},
{'1': 'budget_id', '3': 3, '4': 1, '5': 5, '10': 'budgetId'},
],
};
/// Descriptor for `AddWasteTextReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List addWasteTextReqDescriptor = $convert.base64Decode(
'Cg9BZGRXYXN0ZVRleHRSZXESEgoEdGV4dBgBIAEoCVIEdGV4dBIfCgtjYXRlZ29yeV9pZBgCIA'
'EoBVIKY2F0ZWdvcnlJZBIbCglidWRnZXRfaWQYAyABKAVSCGJ1ZGdldElk');
@$core.Deprecated('Use wasteDescriptor instead')
const Waste$json = {
'1': 'Waste',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
{'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
{'1': 'price', '3': 3, '4': 1, '5': 5, '10': 'price'},
{'1': 'amount', '3': 4, '4': 1, '5': 2, '10': 'amount'},
],
};
/// Descriptor for `Waste`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List wasteDescriptor = $convert.base64Decode(
'CgVXYXN0ZRIOCgJpZBgBIAEoBVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZRIUCgVwcmljZRgDIA'
'EoBVIFcHJpY2USFgoGYW1vdW50GAQgASgCUgZhbW91bnQ=');
@$core.Deprecated('Use deleteWasteReqDescriptor instead')
const DeleteWasteReq$json = {
'1': 'DeleteWasteReq',
'2': [
{'1': 'id', '3': 1, '4': 1, '5': 5, '10': 'id'},
],
};
/// Descriptor for `DeleteWasteReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List deleteWasteReqDescriptor = $convert.base64Decode(
'Cg5EZWxldGVXYXN0ZVJlcRIOCgJpZBgBIAEoBVICaWQ=');
@$core.Deprecated('Use getCategoriesStatReqDescriptor instead')
const GetCategoriesStatReq$json = {
'1': 'GetCategoriesStatReq',
'2': [
{'1': 'ids', '3': 1, '4': 3, '5': 5, '10': 'ids'},
],
};
/// Descriptor for `GetCategoriesStatReq`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getCategoriesStatReqDescriptor = $convert.base64Decode(
'ChRHZXRDYXRlZ29yaWVzU3RhdFJlcRIQCgNpZHMYASADKAVSA2lkcw==');
@$core.Deprecated('Use categoriesStatDescriptor instead')
const CategoriesStat$json = {
'1': 'CategoriesStat',
'2': [
{'1': 'stat', '3': 1, '4': 3, '5': 11, '6': '.crabs.smm_core.CategoriesStat', '10': 'stat'},
],
};
/// Descriptor for `CategoriesStat`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List categoriesStatDescriptor = $convert.base64Decode(
'Cg5DYXRlZ29yaWVzU3RhdBIyCgRzdGF0GAEgAygLMh4uY3JhYnMuc21tX2NvcmUuQ2F0ZWdvcm'
'llc1N0YXRSBHN0YXQ=');
@$core.Deprecated('Use categoryStatDescriptor instead')
const CategoryStat$json = {
'1': 'CategoryStat',
'2': [
{'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'},
{'1': 'monthly_limit', '3': 2, '4': 1, '5': 5, '10': 'monthlyLimit'},
{'1': 'amount', '3': 3, '4': 1, '5': 5, '10': 'amount'},
],
};
/// Descriptor for `CategoryStat`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List categoryStatDescriptor = $convert.base64Decode(
'CgxDYXRlZ29yeVN0YXQSEgoEbmFtZRgBIAEoCVIEbmFtZRIjCg1tb250aGx5X2xpbWl0GAIgAS'
'gFUgxtb250aGx5TGltaXQSFgoGYW1vdW50GAMgASgFUgZhbW91bnQ=');
+33
View File
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:smm_mobile/generated/smm_core.pbgrpc.dart';
import 'src/app.dart';
import 'client.dart';
import 'user_service.dart';
import 'src/settings/settings_controller.dart';
import 'src/settings/settings_service.dart';
void main() async {
final client = SmmCoreTerminalClient();
final userService = UserService(client);
// Set up the SettingsController, which will glue user settings to multiple
// Flutter Widgets.
final settingsController = SettingsController(SettingsService());
// Load the user's preferred theme while the splash screen is displayed.
// This prevents a sudden theme change when the app is first displayed.
await settingsController.loadSettings();
// Run the app and pass in the SettingsController. The app listens to the
// SettingsController for changes, then passes it further down to the
// SettingsView.
runApp(
MyApp(
settingsController: settingsController,
client: client,
userService: userService,
),
);
}
+92
View File
@@ -0,0 +1,92 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'sample_feature/sample_item_details_view.dart';
import 'sample_feature/sample_item_list_view.dart';
import 'settings/settings_controller.dart';
import 'settings/settings_view.dart';
import '../client.dart';
import '../user_service.dart';
/// The Widget that configures your application.
class MyApp extends StatelessWidget {
const MyApp({
super.key,
required this.settingsController,
required this.client,
required this.userService,
});
final SettingsController settingsController;
final SmmCoreTerminalClient client;
final UserService userService;
@override
Widget build(BuildContext context) {
// Glue the SettingsController to the MaterialApp.
//
// The ListenableBuilder Widget listens to the SettingsController for changes.
// Whenever the user updates their settings, the MaterialApp is rebuilt.
return ListenableBuilder(
listenable: settingsController,
builder: (BuildContext context, Widget? child) {
return MaterialApp(
// Providing a restorationScopeId allows the Navigator built by the
// MaterialApp to restore the navigation stack when a user leaves and
// returns to the app after it has been killed while running in the
// background.
restorationScopeId: 'app',
// Provide the generated AppLocalizations to the MaterialApp. This
// allows descendant Widgets to display the correct translations
// depending on the user's locale.
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en', ''), // English, no country code
],
// Use AppLocalizations to configure the correct application title
// depending on the user's locale.
//
// The appTitle is defined in .arb files found in the localization
// directory.
onGenerateTitle: (BuildContext context) =>
AppLocalizations.of(context)!.appTitle,
// Define a light and dark color theme. Then, read the user's
// preferred ThemeMode (light, dark, or system default) from the
// SettingsController to display the correct theme.
theme: ThemeData(),
darkTheme: ThemeData.dark(),
themeMode: settingsController.themeMode,
// Define a function to handle named routes in order to support
// Flutter web url navigation and deep linking.
onGenerateRoute: (RouteSettings routeSettings) {
return MaterialPageRoute<void>(
settings: routeSettings,
builder: (BuildContext context) {
switch (routeSettings.name) {
case SettingsView.routeName:
return SettingsView(controller: settingsController);
case SampleItemDetailsView.routeName:
return const SampleItemDetailsView();
case SampleItemListView.routeName:
default:
return SampleItemListView(client: client);
}
},
);
},
);
},
);
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"appTitle": "smm_mobile",
"@appTitle": {
"description": "The title of the application"
}
}
+6
View File
@@ -0,0 +1,6 @@
/// A placeholder class that represents an entity or model.
class SampleItem {
const SampleItem(this.id);
final int id;
}
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
/// Displays detailed information about a SampleItem.
class SampleItemDetailsView extends StatelessWidget {
const SampleItemDetailsView({super.key});
static const routeName = '/sample_item';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Item Details'),
),
body: const Center(
child: Text('More Information Here'),
),
);
}
}
@@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
import 'package:smm_mobile/generated/smm_core.pbgrpc.dart';
import '../settings/settings_view.dart';
import 'sample_item.dart';
import 'sample_item_details_view.dart';
import '../../client.dart';
/// Displays a list of SampleItems.
class SampleItemListView extends StatelessWidget {
const SampleItemListView({
super.key,
required this.client,
// this.items = const [SampleItem(1), SampleItem(2), SampleItem(3)],
this.items = const [SampleItem(1)],
});
static const routeName = '/';
final List<SampleItem> items;
final SmmCoreTerminalClient client;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Items'),
actions: [
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {
// Navigate to the settings page. If the user leaves and returns
// to the app after it has been killed while running in the
// background, the navigation stack is restored.
Navigator.restorablePushNamed(context, SettingsView.routeName);
},
),
],
),
// To work with lists that may contain a large number of items, its best
// to use the ListView.builder constructor.
//
// In contrast to the default ListView constructor, which requires
// building all Widgets up front, the ListView.builder constructor lazily
// builds Widgets as theyre scrolled into view.
body: ListView.builder(
// Providing a restorationId allows the ListView to restore the
// scroll position when a user leaves and returns to the app after it
// has been killed while running in the background.
restorationId: 'sampleItemListView',
itemCount: items.length,
itemBuilder: (BuildContext context, int index) {
final item = items[index];
return ListTile(
title: Text('ping ${item.id}'),
leading: const CircleAvatar(
// Display the Flutter Logo image asset.
foregroundImage: AssetImage('assets/images/flutter_logo.png'),
),
onTap: () async {
// Navigate to the details page. If the user leaves and returns to
// the app after it has been killed while running in the
// background, the navigation stack is restored.
// Navigator.restorablePushNamed(
// context,
// SampleItemDetailsView.routeName,
// );
await client.stub.ping(PingReq());
});
},
),
);
}
}
+50
View File
@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'settings_service.dart';
/// A class that many Widgets can interact with to read user settings, update
/// user settings, or listen to user settings changes.
///
/// Controllers glue Data Services to Flutter Widgets. The SettingsController
/// uses the SettingsService to store and retrieve user settings.
class SettingsController with ChangeNotifier {
SettingsController(this._settingsService);
// Make SettingsService a private variable so it is not used directly.
final SettingsService _settingsService;
// Make ThemeMode a private variable so it is not updated directly without
// also persisting the changes with the SettingsService.
late ThemeMode _themeMode;
// Allow Widgets to read the user's preferred ThemeMode.
ThemeMode get themeMode => _themeMode;
/// Load the user's settings from the SettingsService. It may load from a
/// local database or the internet. The controller only knows it can load the
/// settings from the service.
Future<void> loadSettings() async {
_themeMode = await _settingsService.themeMode();
// Important! Inform listeners a change has occurred.
notifyListeners();
}
/// Update and persist the ThemeMode based on the user's selection.
Future<void> updateThemeMode(ThemeMode? newThemeMode) async {
if (newThemeMode == null) return;
// Do not perform any work if new and old ThemeMode are identical
if (newThemeMode == _themeMode) return;
// Otherwise, store the new ThemeMode in memory
_themeMode = newThemeMode;
// Important! Inform listeners a change has occurred.
notifyListeners();
// Persist the changes to a local database or the internet using the
// SettingService.
await _settingsService.updateThemeMode(newThemeMode);
}
}
+17
View File
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
/// A service that stores and retrieves user settings.
///
/// By default, this class does not persist user settings. If you'd like to
/// persist the user settings locally, use the shared_preferences package. If
/// you'd like to store settings on a web server, use the http package.
class SettingsService {
/// Loads the User's preferred ThemeMode from local or remote storage.
Future<ThemeMode> themeMode() async => ThemeMode.system;
/// Persists the user's preferred ThemeMode to local or remote storage.
Future<void> updateThemeMode(ThemeMode theme) async {
// Use the shared_preferences package to persist settings locally or the
// http package to persist settings over the network.
}
}
+51
View File
@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';
import 'settings_controller.dart';
/// Displays the various settings that can be customized by the user.
///
/// When a user changes a setting, the SettingsController is updated and
/// Widgets that listen to the SettingsController are rebuilt.
class SettingsView extends StatelessWidget {
const SettingsView({super.key, required this.controller});
static const routeName = '/settings';
final SettingsController controller;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Settings'),
),
body: Padding(
padding: const EdgeInsets.all(16),
// Glue the SettingsController to the theme selection DropdownButton.
//
// When a user selects a theme from the dropdown list, the
// SettingsController is updated, which rebuilds the MaterialApp.
child: DropdownButton<ThemeMode>(
// Read the selected themeMode from the controller
value: controller.themeMode,
// Call the updateThemeMode method any time the user selects a theme.
onChanged: controller.updateThemeMode,
items: const [
DropdownMenuItem(
value: ThemeMode.system,
child: Text('System Theme'),
),
DropdownMenuItem(
value: ThemeMode.light,
child: Text('Light Theme'),
),
DropdownMenuItem(
value: ThemeMode.dark,
child: Text('Dark Theme'),
)
],
),
),
);
}
}
+9
View File
@@ -0,0 +1,9 @@
import '../client.dart';
class UserService {
const UserService({
required this.client,
});
final SmmCoreTerminalClient client;
}