-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9295d90
commit 9e104ab
Showing
6 changed files
with
103 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:gruene_app/app/services/gruene_api_core.dart'; | ||
import 'package:gruene_app/swagger_generated_code/gruene_api.swagger.dart'; | ||
|
||
Future<List<GnetzApplication>> fetchTools() async => getFromApi( | ||
request: (api) => api.v1GnetzApplicationsGet(), | ||
map: (data) => data.data, | ||
); | ||
|
||
List<GnetzApplicationCategory> getToolCategories(List<GnetzApplication> tools) { | ||
final categories = tools.map((tool) => tool.categories).expand((it) => it).toSet().toList(); | ||
categories.sort((a, b) => a.order.compareTo(b.order)); | ||
return categories; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:gruene_app/app/theme/theme.dart'; | ||
import 'package:gruene_app/i18n/translations.g.dart'; | ||
import 'package:gruene_app/app/screens/future_loading_screen.dart'; | ||
import 'package:gruene_app/app/screens/tab_screen.dart'; | ||
import 'package:gruene_app/app/widgets/main_layout.dart'; | ||
import 'package:gruene_app/app/widgets/tab_bar.dart'; | ||
import 'package:gruene_app/features/tools/domain/tools_api_service.dart'; | ||
import 'package:gruene_app/features/tools/widgets/tools_list.dart'; | ||
import 'package:gruene_app/swagger_generated_code/gruene_api.swagger.dart'; | ||
|
||
class ToolsScreen extends StatelessWidget { | ||
const ToolsScreen({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
return Padding( | ||
padding: const EdgeInsets.fromLTRB(24, 33, 24, 26), | ||
child: Center( | ||
child: Text( | ||
t.common.notImplementedYet, | ||
style: theme.textTheme.bodyLarge?.apply(color: ThemeColors.text), | ||
textAlign: TextAlign.center, | ||
), | ||
), | ||
return FutureLoadingScreen( | ||
load: fetchTools, | ||
layoutBuilder: (Widget child) => MainLayout(child: child), | ||
buildChild: (List<GnetzApplication> data) { | ||
final tabs = getToolCategories(data) | ||
.map( | ||
(category) => TabModel( | ||
label: category.title, | ||
view: ToolsList(tools: data.where((tool) => tool.categories.contains(category)).toList()), | ||
), | ||
) | ||
.toList(); | ||
|
||
return TabScreen(tabs: tabs); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_svg/flutter_svg.dart'; | ||
import 'package:gruene_app/app/constants/config.dart'; | ||
import 'package:gruene_app/app/utils/open_url.dart'; | ||
import 'package:gruene_app/features/settings/widgets/settings_card.dart'; | ||
import 'package:gruene_app/swagger_generated_code/gruene_api.swagger.dart'; | ||
|
||
class ToolsList extends StatelessWidget { | ||
final List<GnetzApplication> tools; | ||
|
||
const ToolsList({super.key, required this.tools}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ListView( | ||
padding: const EdgeInsets.all(16), | ||
children: tools.map( | ||
(tool) { | ||
final icon = tool.icon; | ||
final url = tool.url; | ||
return SettingsCard( | ||
title: tool.title, | ||
subtitle: tool.shortDescription[Config.defaultLocale] as String? ?? '', | ||
onPress: url != null ? () => openUrl(url, context) : null, | ||
isExternal: true, | ||
icon: icon != null ? SvgPicture.string(icon, width: 48, height: 48) : SizedBox(width: 48, height: 48), | ||
); | ||
}, | ||
).toList(), | ||
); | ||
} | ||
} |