Initial (redacted) commit.
This commit is contained in:
commit
655f8a036a
368 changed files with 20949 additions and 0 deletions
150
app/lib/infrastructure/widget_wall/add_widget_menu.dart
Normal file
150
app/lib/infrastructure/widget_wall/add_widget_menu.dart
Normal file
|
@ -0,0 +1,150 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:habitrack_app/infrastructure/widget_wall/items_controller.dart';
|
||||
import 'package:habitrack_app/main.dart';
|
||||
import 'package:habitrack_app/sembast/hydration.dart';
|
||||
import 'package:habitrack_app/sembast/tasks_list.dart';
|
||||
import 'package:habitrack_app/sembast/timer.dart';
|
||||
|
||||
//Add Widget to List- Button Class ######################################
|
||||
class _AddWidgetToList extends ConsumerWidget {
|
||||
const _AddWidgetToList({
|
||||
required this.toAdd,
|
||||
required this.buttonText,
|
||||
required this.iconData,
|
||||
});
|
||||
|
||||
final dynamic toAdd;
|
||||
final String buttonText;
|
||||
final IconData iconData;
|
||||
|
||||
void _buttonFunc(BuildContext context, WidgetRef ref) {
|
||||
//ref.read(widgetListNotifierProvider.notifier).addWidget(toAdd());
|
||||
//ref.read(homeControllerProvider).add()
|
||||
ref.watch(homeControllerProvider).add(toAdd);
|
||||
|
||||
Navigator.pop(context);
|
||||
logger.i('Button Func Called');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0x00000000).withOpacity(0.25),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 2,
|
||||
),
|
||||
],
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
width: 300,
|
||||
child: TextButton(
|
||||
onPressed: () => {_buttonFunc(context, ref)},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
iconData,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
Text(
|
||||
buttonText,
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// AddWidgetMenu ##########################################################
|
||||
class AddWidgetMenu extends StatelessWidget {
|
||||
const AddWidgetMenu({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//AddWidgetToList - Button-Instances #######################################
|
||||
final addWaterWidget = _AddWidgetToList(
|
||||
toAdd: Hydration(
|
||||
createdOn: DateTime.now().toString(),
|
||||
completedOn: '',
|
||||
isVisible: true,
|
||||
widgetType: 'Hydration',
|
||||
name: AppLocalizations.of(context)!.waterWidget_defaultName,
|
||||
button1Amount: 100,
|
||||
button2Amount: 250,
|
||||
goal: 2500,
|
||||
current: 0,
|
||||
isExpanded: false,
|
||||
),
|
||||
buttonText: AppLocalizations.of(context)!.addWidget_water,
|
||||
iconData: Icons.local_drink,
|
||||
);
|
||||
|
||||
final addCompoundTimerWidget = _AddWidgetToList(
|
||||
toAdd: TimerItem(
|
||||
widgetType: 'Timer',
|
||||
name: AppLocalizations.of(context)!.timerWidget_defaultName,
|
||||
current: 0,
|
||||
goal: 90,
|
||||
isExpanded: false,
|
||||
createdOn: DateTime.now().toString(),
|
||||
completedOn: '',
|
||||
isVisible: true,
|
||||
state: 'initial',
|
||||
),
|
||||
buttonText: AppLocalizations.of(context)!.addWidget_timer,
|
||||
iconData: Icons.timer,
|
||||
);
|
||||
final addTaskWidget = _AddWidgetToList(
|
||||
toAdd: TasksItem(
|
||||
isVisible: true,
|
||||
widgetType: 'TODO',
|
||||
name: AppLocalizations.of(context)!.tasksWidget_defaultName,
|
||||
isExpanded: false,
|
||||
taskList: [],
|
||||
completedTaskList: [],
|
||||
),
|
||||
buttonText: AppLocalizations.of(context)!.addWidget_tasks,
|
||||
iconData: Icons.task,
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
iconTheme: IconThemeData(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.addWidgetHeader,
|
||||
textScaler: const TextScaler.linear(1.5),
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
foregroundColor: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
body: Container(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
addWaterWidget,
|
||||
addTaskWidget,
|
||||
addCompoundTimerWidget,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue