forked from yumemi-inc/flutter-engineer-codecheck
-
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.
Merge pull request #13 from tuxsnct/feature/temporary-home
仮のホーム画面を作成
- Loading branch information
Showing
3 changed files
with
37 additions
and
47 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
57 changes: 31 additions & 26 deletions
57
lib/features/common/presentation/screens/home_screen.dart
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,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), | ||
), | ||
); | ||
} | ||
} |
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,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); | ||
}); | ||
} |