Skip to content

Commit

Permalink
Merge pull request #13 from tuxsnct/feature/temporary-home
Browse files Browse the repository at this point in the history
仮のホーム画面を作成
  • Loading branch information
tuxsnct authored Apr 5, 2024
2 parents dc06916 + c2a0eb1 commit 4022e45
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 47 deletions.
3 changes: 1 addition & 2 deletions lib/config/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ class HomeRoute extends GoRouteData {
const HomeRoute() : super();

@override
Widget build(BuildContext context, GoRouterState state) =>
const HomeScreen(title: 'Flutter Demo Home Page');
Widget build(BuildContext context, GoRouterState state) => const HomeScreen();
}
57 changes: 31 additions & 26 deletions lib/features/common/presentation/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
const HomeScreen({required this.title, super.key});

final String title;
const HomeScreen({super.key});

@override
State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
int _counter = 0;

void _incrementCounter() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
body: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
'GitHub Viewer',
key: const Key('title'),
style: Theme.of(context).textTheme.displayLarge,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
const SizedBox(height: 32),
FilledButton.tonal(
key: const Key('search_button'),
onPressed: () {},
style: FilledButton.styleFrom(
minimumSize: const Size.fromHeight(90),
),
child: SizedBox(
width: double.maxFinite,
child: Wrap(
alignment: WrapAlignment.spaceBetween,
children: <Widget>[
Text(
'Search',
style: Theme.of(context).textTheme.headlineSmall,
overflow: TextOverflow.ellipsis,
),
const Icon(Icons.search, size: 32),
],
),
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
24 changes: 5 additions & 19 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:github_viewer/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
testWidgets('HomeScreenにタイトルと検索ボタンが表示されること', (WidgetTester tester) async {
await tester.pumpWidget(const GithubViewerApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// タイトルが表示されていることを確認
expect(find.byKey(const Key('title')), findsOneWidget);

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
// 検索ボタンが表示されていることを確認
expect(find.byKey(const Key('search_button')), findsOneWidget);
});
}

0 comments on commit 4022e45

Please sign in to comment.