diff --git a/lib/contributors_page.dart b/lib/contributors_page.dart index 3a75f1a..fab9806 100644 --- a/lib/contributors_page.dart +++ b/lib/contributors_page.dart @@ -1,16 +1,10 @@ import 'package:flutter/material.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; -import 'constants.dart'; import 'contributor_grid.dart'; import 'contributor_service.dart'; -import 'foot_note.dart'; -import 'header_lead.dart'; -import 'header_title.dart'; -import 'message_fab.dart'; -import 'scaffold_gradient.dart'; import 'splash_screen.dart'; -import 'top_menu_entry.dart'; +import 'sub_page.dart'; class ContributorsPage extends StatefulWidget { const ContributorsPage({super.key}); @@ -36,24 +30,8 @@ class _ContributorsPageState extends State { @override Widget build(BuildContext context) { - return Container( - decoration: scaffoldGradient(context), - child: Scaffold( - bottomNavigationBar: const FootNote(), - backgroundColor: Colors.transparent, - appBar: AppBar( - backgroundColor: Colors.transparent, - toolbarHeight: kToolBarHeight, - leadingWidth: kLeadingWidth, - leading: const HeaderLead( - insertBackButton: true, - ), - title: const HeaderTitle(), - actions: createTopMenu(context), - ), - body: initialized ? const ContributorGrid() : const SplashScreen(), - floatingActionButton: const MessageFab(), - ), + return SubPage( + body: initialized ? const ContributorGrid() : const SplashScreen(), ); } } diff --git a/lib/getting_started_page.dart b/lib/getting_started_page.dart index 50a359b..dd24f0b 100644 --- a/lib/getting_started_page.dart +++ b/lib/getting_started_page.dart @@ -5,13 +5,7 @@ import 'package:yaru_widgets/constants.dart'; import 'package:yaru_widgets/widgets.dart'; import 'build_context_x.dart'; -import 'constants.dart'; -import 'foot_note.dart'; -import 'header_lead.dart'; -import 'header_title.dart'; -import 'message_fab.dart'; -import 'scaffold_gradient.dart'; -import 'top_menu_entry.dart'; +import 'sub_page.dart'; class GettingStartedPage extends StatelessWidget { const GettingStartedPage({super.key}); @@ -19,40 +13,26 @@ class GettingStartedPage extends StatelessWidget { @override Widget build(BuildContext context) { final width = context.mq.size.width; - return Container( - decoration: scaffoldGradient(context), - child: Scaffold( - backgroundColor: Colors.transparent, - appBar: AppBar( - title: const HeaderTitle(), - backgroundColor: Colors.transparent, - toolbarHeight: kToolBarHeight, - leadingWidth: kLeadingWidth, - leading: const HeaderLead(), - actions: createTopMenu(context), - ), - body: Center( - child: FutureBuilder( - future: loadMarkdown(), - builder: (context, shot) { - if (!shot.hasData) { - return const Center( - child: YaruCircularProgressIndicator(), - ); - } - - return Markdown( - padding: EdgeInsets.symmetric( - vertical: kYaruPagePadding, - horizontal: width < 700 ? kYaruPagePadding : width * 0.2, - ), - data: shot.data!, + return SubPage( + body: Center( + child: FutureBuilder( + future: loadMarkdown(), + builder: (context, shot) { + if (!shot.hasData) { + return const Center( + child: YaruCircularProgressIndicator(), ); - }, - ), + } + + return Markdown( + padding: EdgeInsets.symmetric( + vertical: kYaruPagePadding, + horizontal: width < 700 ? kYaruPagePadding : width * 0.2, + ), + data: shot.data!, + ); + }, ), - bottomNavigationBar: const FootNote(), - floatingActionButton: const MessageFab(), ), ); } diff --git a/lib/home_page.dart b/lib/home_page.dart index 5594e00..1197e84 100644 --- a/lib/home_page.dart +++ b/lib/home_page.dart @@ -5,74 +5,55 @@ import 'package:universal_html/html.dart' as html; import 'build_context_x.dart'; import 'constants.dart'; -import 'foot_note.dart'; -import 'header_lead.dart'; -import 'header_title.dart'; -import 'message_fab.dart'; import 'plated_icon.dart'; import 'repositories.dart'; -import 'scaffold_gradient.dart'; import 'screen_message.dart'; -import 'top_menu_entry.dart'; +import 'sub_page.dart'; class HomePage extends StatelessWidget { const HomePage({super.key}); @override Widget build(BuildContext context) { - return Container( - decoration: scaffoldGradient(context), - child: Scaffold( - bottomNavigationBar: const FootNote(), - backgroundColor: Colors.transparent, - floatingActionButton: const MessageFab(), - appBar: AppBar( - backgroundColor: Colors.transparent, - toolbarHeight: kToolBarHeight, - leadingWidth: kLeadingWidth, - leading: const HeaderLead(), - title: const HeaderTitle(), - actions: createTopMenu(context), - ), - body: SizedBox( - height: context.mq.size.height, - child: ListView( - padding: const EdgeInsets.all(50), - children: [ - ScreenMessage( - title: Shimmer.fromColors( - loop: 1, - period: const Duration(seconds: 3), - baseColor: kBaseColor, - highlightColor: kHighlightColor, - child: const Text(kWelcomeTitle), - ), - subTitle: Shimmer.fromColors( - baseColor: kBaseColor, - highlightColor: kHighlightColor, - child: InkWell( - borderRadius: BorderRadius.circular(5), - onTap: () => Navigator.of(context).pushNamed('/projects'), - child: const Text(kWelcomeButtonText), - ), + return SubPage( + body: SizedBox( + height: context.mq.size.height, + child: ListView( + padding: const EdgeInsets.all(50), + children: [ + ScreenMessage( + title: Shimmer.fromColors( + loop: 1, + period: const Duration(seconds: 3), + baseColor: kBaseColor, + highlightColor: kHighlightColor, + child: const Text(kWelcomeTitle), + ), + subTitle: Shimmer.fromColors( + baseColor: kBaseColor, + highlightColor: kHighlightColor, + child: InkWell( + borderRadius: BorderRadius.circular(5), + onTap: () => Navigator.of(context).pushNamed('/projects'), + child: const Text(kWelcomeButtonText), ), - label: const Text(kAppTitle), ), - ...repositories.map( - (e) => ScreenMessage( - label: Text(e.$1), - title: Text(e.$2), - subTitle: Text(e.$3), - icon: PlatedIcon( - onTap: () => - html.window.open(p.join(kGitHubPrefix, e.$1, e.$2), ''), - icon: e.$4, - shape: e.$2 == 'settings' ? BoxShape.circle : null, - ), + label: const Text(kAppTitle), + ), + ...repositories.map( + (e) => ScreenMessage( + label: Text(e.$1), + title: Text(e.$2), + subTitle: Text(e.$3), + icon: PlatedIcon( + onTap: () => + html.window.open(p.join(kGitHubPrefix, e.$1, e.$2), ''), + icon: e.$4, + shape: e.$2 == 'settings' ? BoxShape.circle : null, ), ), - ], - ), + ), + ], ), ), ); diff --git a/lib/projects_page.dart b/lib/projects_page.dart index d527fa9..bb9db0c 100644 --- a/lib/projects_page.dart +++ b/lib/projects_page.dart @@ -1,35 +1,15 @@ import 'package:flutter/material.dart'; -import 'constants.dart'; -import 'foot_note.dart'; -import 'header_lead.dart'; -import 'header_title.dart'; -import 'message_fab.dart'; import 'projects_list.dart'; -import 'scaffold_gradient.dart'; -import 'top_menu_entry.dart'; +import 'sub_page.dart'; class ProjectsPage extends StatelessWidget { const ProjectsPage({super.key}); @override Widget build(BuildContext context) { - return Container( - decoration: scaffoldGradient(context), - child: Scaffold( - bottomNavigationBar: const FootNote(), - backgroundColor: Colors.transparent, - floatingActionButton: const MessageFab(), - appBar: AppBar( - backgroundColor: Colors.transparent, - toolbarHeight: kToolBarHeight, - leadingWidth: kLeadingWidth, - leading: const HeaderLead(), - title: const HeaderTitle(), - actions: createTopMenu(context), - ), - body: const ProjectsList(), - ), + return const SubPage( + body: ProjectsList(), ); } } diff --git a/lib/sub_page.dart b/lib/sub_page.dart new file mode 100644 index 0000000..9a2be38 --- /dev/null +++ b/lib/sub_page.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; + +import 'constants.dart'; +import 'foot_note.dart'; +import 'header_lead.dart'; +import 'header_title.dart'; +import 'message_fab.dart'; +import 'scaffold_gradient.dart'; +import 'top_menu_entry.dart'; + +class SubPage extends StatelessWidget { + const SubPage({super.key, required this.body}); + + final Widget body; + + @override + Widget build(BuildContext context) { + return Container( + decoration: scaffoldGradient(context), + child: Scaffold( + bottomNavigationBar: const FootNote(), + backgroundColor: Colors.transparent, + appBar: AppBar( + backgroundColor: Colors.transparent, + toolbarHeight: kToolBarHeight, + leadingWidth: kLeadingWidth, + leading: const HeaderLead( + insertBackButton: true, + ), + title: const HeaderTitle(), + actions: createTopMenu(context), + ), + body: body, + floatingActionButton: const MessageFab(), + ), + ); + } +}