Skip to content

Commit

Permalink
feat: add settings screen delete action
Browse files Browse the repository at this point in the history
  • Loading branch information
luisburgos committed Jul 23, 2022
1 parent 8855181 commit 1d19fd5
Show file tree
Hide file tree
Showing 58 changed files with 109 additions and 293 deletions.
3 changes: 2 additions & 1 deletion example/lib/get/core_module.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:buzz/buzz.dart';
import 'package:get/get.dart';
import 'package:profile/profile.dart';

import '../shared/modules/profile/data/profile_repository.dart';
import '../shared/modules/profile/module_registry.dart';
import 'extensions/get_module.dart';
import 'home/module.dart';
import 'overrides/app_navigator.dart';
Expand Down
2 changes: 1 addition & 1 deletion example/lib/get/profile/module.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:example/get/profile/page.dart';
import 'package:get/get.dart';
import 'package:profile/profile.dart';

import '../../shared/modules/profile/data/profile_repository.dart';
import '../extensions/get_module.dart';

class ProfileModule extends GetModule {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/get/profile/page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:buzz/buzz.dart';
import 'package:get/get.dart';
import 'package:profile/profile.dart';

import '../../shared/app_routes.dart';
import '../../shared/modules/profile/presentation/screen.dart';
import '../extensions/get_module.dart';

class ProfileRoute extends GetRoute {
Expand Down
3 changes: 2 additions & 1 deletion example/lib/modular/core_module.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:buzz/buzz.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:profile/profile.dart';

import '../shared/app_routes.dart';
import '../shared/modules/profile/data/profile_repository.dart';
import '../shared/modules/profile/module_registry.dart';
import '../shared/not_found_page.dart';
import 'home/home_module.dart';
import 'overrides/app_navigator.dart';
Expand Down
2 changes: 1 addition & 1 deletion example/lib/modular/profile/module.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter_modular/flutter_modular.dart';
import 'package:profile/profile.dart';

import '../../shared/modules/profile/data/profile_repository.dart';
import 'page.dart';

class ProfileModule extends Module {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/modular/profile/page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:buzz/buzz.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:profile/profile.dart';

import '../../shared/app_routes.dart';
import '../../shared/modules/profile/presentation/screen.dart';

class ProfileRoute extends ChildRoute {
ProfileRoute()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:buzz/buzz.dart';

import '../profile.dart';
import '../data/profile_repository.dart';

class ChangeUserNameCommand extends Command {
ChangeUserNameCommand({required this.newName});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:core/in_memory_store.dart';
import 'package:buzz_ui/in_memory_events_store.dart';

import '../model/profile.dart';
import '../model/profile_user_info.dart';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:buzz/buzz.dart';
import 'package:profile/data/profile_repository.dart';
import 'package:profile/presentation/ui_event.dart';

import 'commands/change_user_name_command.dart';
import 'data/profile_repository.dart';
import 'presentation/ui_event.dart';

class ProfileModuleRegistries extends ModuleBuzzRegistries {
ProfileModuleRegistries(this.findRepository);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:profile/presentation/view.dart';

import 'view.dart';

class ProfileScreen extends StatelessWidget {
const ProfileScreen({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:buzz/buzz.dart';
import 'package:get/get.dart';
import 'package:profile/data/profile_repository.dart';

import '../data/profile_repository.dart';
import '../model/profile.dart';
import 'ui_event.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

import '../profile.dart';
import '../model/profile_option.dart';

class ProfileViewTemplate extends StatelessWidget {
const ProfileViewTemplate({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:buzz/buzz.dart';
import 'package:buzz_ui/events_list_view.dart';
import 'package:core/core.dart';
import 'package:flutter/material.dart';
Expand All @@ -7,24 +6,34 @@ import 'package:get/get.dart';
import 'view_controller.dart';

class SettingsScreen extends StatelessWidget {
const SettingsScreen({Key? key}) : super(key: key);
const SettingsScreen({
Key? key,
required this.mainActionRoute,
}) : super(key: key);

final String mainActionRoute;

@override
Widget build(BuildContext context) {
final controller = Get.put(SettingsViewController());
final controller = Get.put(
SettingsViewController(
mainActionRoute: mainActionRoute,
),
);

return Obx(() {
return BasePage(
name: 'Profile/Settings',
body: EventRecordsView(
eventsStoreStream: controller.eventsStore,
onDeleteEventsPressed: () {
controller.onDeleteEventsPressed();
},
),
action: MainAction(
label: 'Go to the unknown',
onPressed: () {
Buzz.fire(
NavigateToCommand.named('/asdasd'),
);
controller.onMainActionPressed();
},
),
);
Expand Down
23 changes: 23 additions & 0 deletions example/lib/shared/modules/profile/settings/view_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:buzz/buzz.dart';
import 'package:buzz_ui/in_memory_events_store.dart';
import 'package:get/get.dart';

class SettingsViewController extends GetxController {
SettingsViewController({
required this.mainActionRoute,
});

final String mainActionRoute;

Stream<List<EventRecord>> get eventsStore {
return Get.find<EventRecordsInMemoryStore>().listStateChanges();
}

void onDeleteEventsPressed() {}

void onMainActionPressed() {
Buzz.fire(
NavigateToCommand.named(mainActionRoute),
);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
import 'package:core/core.dart';
import 'package:flutter/material.dart';

import 'in_memory_events_store.dart';

///TODO: Add clear events cache log action
class EventRecordsView extends StatelessWidget {
static const String routeName = "/app-behavior";
static const String routeName = "/buzz-events";

const EventRecordsView({
Key? key,
required this.eventsStoreStream,
this.customColorDecorator,
required this.onDeleteEventsPressed,
}) : super(key: key);

final Stream<List<EventRecord>> eventsStoreStream;
final Color Function(EventRecord)? customColorDecorator;
final Function() onDeleteEventsPressed;

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
actions: [
IconButton(
icon: const Icon(Icons.delete_forever),
onPressed: onDeleteEventsPressed,
)
],
),
body: EventRecordsViewStreamBuilder(
eventsStoreStream: eventsStoreStream,
customColorDecorator: customColorDecorator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
import 'package:rxdart/rxdart.dart' show BehaviorSubject;
import 'package:rxdart/rxdart.dart';

abstract class EventRecord {
String get name;
Map<String, dynamic>? get params;
DateTime get timestamp;

@override
String toString() {
return "[$name, $params, $timestamp]";
}
}

class EventRecordsInMemoryStore {
final _state = InMemoryStore<List<EventRecord>>([]);

Stream<List<EventRecord>> listStateChanges() => _state.stream;

List<EventRecord> get currentList => _state.value;

Future<void> loadList() async {
//TODO: Implement loading items from a local file or a remote.
}

Future<void> wipeList() async {
_state.value = [];
}

void dispose() => _state.close();

void add(EventRecord event) {
_state.value.add(event);
}
}

/// An in-memory store backed by BehaviorSubject that can be used to
/// store the data for all the fake repositories in the app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
rxdart: 0.27.4
core:
path: '../../packages/core'

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
library core;

export 'event_record.dart';
export 'in_memory_store.dart';
export 'json_reader.dart';
export 'managed_stream_builder.dart';
export 'named_page.dart';
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 0 additions & 29 deletions example/profile/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions example/profile/lib/profile.dart

This file was deleted.

8 changes: 0 additions & 8 deletions example/profile/lib/settings/view_controller.dart

This file was deleted.

62 changes: 0 additions & 62 deletions example/profile/pubspec.yaml

This file was deleted.

Loading

0 comments on commit 1d19fd5

Please sign in to comment.