From 511e8cda7607ecf5c6f819569cf7db38ba96f2bb Mon Sep 17 00:00:00 2001 From: Hydroxycarbamide Date: Sun, 8 May 2022 23:56:23 +0200 Subject: [PATCH] Added somes pages --- lib/main.dart | 17 +++-- lib/page/about_page.dart | 21 ++++++ lib/page/actions_page.dart | 13 ---- lib/page/more_page.dart | 63 ++++++++++++++++++ lib/page/repos_page.dart | 11 +++- lib/page/settings_page.dart | 21 ++++++ .../colors_schemes/lib_color_schemes.g.dart | 65 +++++++++++++++++++ pubspec.lock | 23 +++---- test/widget_test.dart | 10 +-- 9 files changed, 204 insertions(+), 40 deletions(-) create mode 100644 lib/page/about_page.dart delete mode 100644 lib/page/actions_page.dart create mode 100644 lib/page/more_page.dart create mode 100644 lib/page/settings_page.dart create mode 100644 lib/resources/colors_schemes/lib_color_schemes.g.dart diff --git a/lib/main.dart b/lib/main.dart index 02561c2..ac4ed91 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,9 @@ import 'dart:math'; import 'package:flutter/material.dart'; +import 'package:simple_git/resources/colors_schemes/lib_color_schemes.g.dart'; -import 'page/actions_page.dart'; +import 'page/more_page.dart'; import 'page/repos_page.dart'; void main() { @@ -34,7 +35,7 @@ class _HomeScreenState extends State { final screens = [ ReposPage(), - ActionPage(), + MorePage(), ]; @override @@ -43,6 +44,7 @@ class _HomeScreenState extends State { body: screens[_index], bottomNavigationBar: NavigationBarTheme( data: NavigationBarThemeData( + indicatorColor: darkColorScheme.primary, labelTextStyle: MaterialStateProperty.all( const TextStyle(fontSize: 14, fontWeight: FontWeight.w500), ), @@ -50,10 +52,13 @@ class _HomeScreenState extends State { child: NavigationBar( height: 70, selectedIndex: _index, - onDestinationSelected: (index) => setState(() => this._index = index), - destinations: const [ - NavigationDestination(icon: Icon(Icons.home_outlined), selectedIcon: Icon(Icons.home), label: 'Repos'), - NavigationDestination(icon: Icon(Icons.add_outlined), selectedIcon: Icon(Icons.add), label: 'Actions') + backgroundColor: lightColorScheme.primaryContainer, + onDestinationSelected: (index) => setState(() { + this._index = index; + }), + destinations: [ + NavigationDestination(icon: Icon(Icons.home_outlined, color: lightColorScheme.onPrimaryContainer), selectedIcon: Icon(Icons.home), label: 'Repos'), + NavigationDestination(icon: Icon(Icons.more_horiz_outlined, color: lightColorScheme.onPrimaryContainer), selectedIcon: Icon(Icons.more_horiz), label: 'More'), ], ), ), diff --git a/lib/page/about_page.dart b/lib/page/about_page.dart new file mode 100644 index 0000000..4851c64 --- /dev/null +++ b/lib/page/about_page.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +import '../resources/colors_schemes/lib_color_schemes.g.dart'; + +class AboutPage extends StatelessWidget { + const AboutPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + iconTheme: IconThemeData( + color: lightColorScheme.onBackground, + ), + title: Text('About', style: TextStyle(color: lightColorScheme.onPrimaryContainer)), + backgroundColor: lightColorScheme.primaryContainer, + elevation: 0, + ), + ); + } +} diff --git a/lib/page/actions_page.dart b/lib/page/actions_page.dart deleted file mode 100644 index fea5c00..0000000 --- a/lib/page/actions_page.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:flutter/material.dart'; - - -class ActionPage extends StatelessWidget { - const ActionPage({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Text('B'), - ); - } -} diff --git a/lib/page/more_page.dart b/lib/page/more_page.dart new file mode 100644 index 0000000..05b3de6 --- /dev/null +++ b/lib/page/more_page.dart @@ -0,0 +1,63 @@ +import 'package:flutter/material.dart'; +import 'package:simple_git/resources/colors_schemes/lib_color_schemes.g.dart'; + +import 'about_page.dart'; +import 'settings_page.dart'; + +class MorePage extends StatefulWidget { + const MorePage({Key? key}) : super(key: key); + + @override + State createState() => _MorePageState(); +} + +class _MorePageState extends State { + final _texts = [ + "Settings", + "About", + ]; + + final _icons = [ + Icons.settings_outlined, + Icons.info_outline, + ]; + + final _pages = [ + SettingsPage(), + AboutPage(), + ]; + + int stateIndex = 0; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('More', + style: TextStyle(color: lightColorScheme.onPrimaryContainer)), + backgroundColor: lightColorScheme.primaryContainer, + elevation: 0, + ), + body: ListView.builder( + // padding: const EdgeInsets.all(20.0), + itemCount: _texts.length, + itemBuilder: (context, index) { + return ListTile( + onTap: () => selectOption(index), + title: Text(_texts[index]), + leading: Icon(_icons[index], color: lightColorScheme.primary), + ); + }, + ), + ); + } + + selectOption(index) { + stateIndex = index; + Navigator.of(context).push(PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => _pages[index], + transitionsBuilder: (c, anim, a2, child) => FadeTransition(opacity: anim, child: child), + transitionDuration: const Duration(milliseconds: 150), + )); + } +} diff --git a/lib/page/repos_page.dart b/lib/page/repos_page.dart index f212f5d..d8d95d3 100644 --- a/lib/page/repos_page.dart +++ b/lib/page/repos_page.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import '../resources/colors_schemes/lib_color_schemes.g.dart'; + class ReposPage extends StatelessWidget { const ReposPage({Key? key}) : super(key: key); @@ -7,7 +9,14 @@ class ReposPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - body: Text('A'), + appBar: AppBar( + title: Text('Repositories', style: TextStyle(color: lightColorScheme.onPrimaryContainer)), + backgroundColor: lightColorScheme.primaryContainer, + elevation: 0, + ), + body: Container( + child: Text('A') + ), ); } } diff --git a/lib/page/settings_page.dart b/lib/page/settings_page.dart new file mode 100644 index 0000000..79cd328 --- /dev/null +++ b/lib/page/settings_page.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +import '../resources/colors_schemes/lib_color_schemes.g.dart'; + +class SettingsPage extends StatelessWidget { + const SettingsPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + iconTheme: IconThemeData( + color: lightColorScheme.onBackground, + ), + title: Text('Settings', style: TextStyle(color: lightColorScheme.onPrimaryContainer)), + backgroundColor: lightColorScheme.primaryContainer, + elevation: 0, + ), + ); + } +} diff --git a/lib/resources/colors_schemes/lib_color_schemes.g.dart b/lib/resources/colors_schemes/lib_color_schemes.g.dart new file mode 100644 index 0000000..dbaaa1b --- /dev/null +++ b/lib/resources/colors_schemes/lib_color_schemes.g.dart @@ -0,0 +1,65 @@ +import 'package:flutter/material.dart'; + +const seed = Color(0xFF3584E4); + +const lightColorScheme = ColorScheme( + brightness: Brightness.light, + primary : Color(0xFF005EB5), + onPrimary : Color(0xFFFFFFFF), + primaryContainer : Color(0xFFD4E3FF), + onPrimaryContainer : Color(0xFF001B3D), + secondary : Color(0xFF555F71), + onSecondary : Color(0xFFFFFFFF), + secondaryContainer : Color(0xFFD9E3F8), + onSecondaryContainer : Color(0xFF121C2B), + tertiary : Color(0xFF6E5675), + onTertiary : Color(0xFFFFFFFF), + tertiaryContainer : Color(0xFFF8D8FE), + onTertiaryContainer : Color(0xFF27132F), + error : Color(0xFFBA1B1B), + errorContainer : Color(0xFFFFDAD4), + onError : Color(0xFFFFFFFF), + onErrorContainer : Color(0xFF410001), + background : Color(0xFFFDFBFF), + onBackground : Color(0xFF1B1B1D), + surface : Color(0xFFFDFBFF), + onSurface : Color(0xFF1B1B1D), + surfaceVariant : Color(0xFFE0E2EB), + onSurfaceVariant : Color(0xFF43474F), + outline : Color(0xFF74777F), + onInverseSurface : Color(0xFFF1F0F4), + inverseSurface : Color(0xFF2F3033), + inversePrimary : Color(0xFFA5C8FF), + shadow : Color(0xFF000000), +); + +const darkColorScheme = ColorScheme( + brightness: Brightness.dark, + primary : Color(0xFFA5C8FF), + onPrimary : Color(0xFF003063), + primaryContainer : Color(0xFF00468A), + onPrimaryContainer : Color(0xFFD4E3FF), + secondary : Color(0xFFBDC7DC), + onSecondary : Color(0xFF273141), + secondaryContainer : Color(0xFF3D4758), + onSecondaryContainer : Color(0xFFD9E3F8), + tertiary : Color(0xFFDBBDE1), + onTertiary : Color(0xFF3E2845), + tertiaryContainer : Color(0xFF553E5D), + onTertiaryContainer : Color(0xFFF8D8FE), + error : Color(0xFFFFB4A9), + errorContainer : Color(0xFF930006), + onError : Color(0xFF680003), + onErrorContainer : Color(0xFFFFDAD4), + background : Color(0xFF1B1B1D), + onBackground : Color(0xFFE3E2E6), + surface : Color(0xFF1B1B1D), + onSurface : Color(0xFFE3E2E6), + surfaceVariant : Color(0xFF43474F), + onSurfaceVariant : Color(0xFFC3C6CF), + outline : Color(0xFF8E919A), + onInverseSurface : Color(0xFF1B1B1D), + inverseSurface : Color(0xFFE3E2E6), + inversePrimary : Color(0xFF005EB5), + shadow : Color(0xFF000000), +); \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 2b17c8d..5605564 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -94,7 +94,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -108,7 +108,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" sky_engine: dependency: transitive description: flutter @@ -120,7 +120,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -155,20 +155,13 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.16.2 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" diff --git a/test/widget_test.dart b/test/widget_test.dart index c35f045..768ee4c 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -16,15 +16,15 @@ void main() { await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. - expect(find.text('A'), findsOneWidget); - expect(find.text('B'), findsNothing); + expect(find.text('Repositories'), findsOneWidget); + expect(find.text('More'), findsOneWidget); // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add_outlined)); + await tester.tap(find.byIcon(Icons.more_horiz_outlined)); await tester.pump(); // Verify that our counter has incremented. - expect(find.text('A'), findsNothing); - expect(find.text('B'), findsOneWidget); + expect(find.text('Repositories'), findsNothing); + expect(find.text('More'), findsWidgets); }); }