123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import 'package:autocomplete_textfield/autocomplete_textfield.dart';
- import 'package:colorize_logger/colorize_logger.dart';
- import 'package:flutter/material.dart';
- import 'package:get_it/get_it.dart';
- import 'package:ustest/BuildHistoryList.dart';
- import 'Services/BuildService.dart';
- class BuildView extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- // TODO: implement createState
- return _BuildView();
- }
- }
- class _BuildView extends State<BuildView> {
- final platforms = ["Windows", "Linux", "IOS"];
- String? selectedPlatform;
- GlobalKey<AutoCompleteTextFieldState<String>> platformKey =
- GlobalKey<AutoCompleteTextFieldState<String>>();
- @override
- Widget build(BuildContext context) {
- Future<List<BuildHistory>> future = fetchBuildHistories();
- GlobalKey listKey = GlobalKey();
- return Scaffold(
- body: Center(
- child: Column(
- children: [
- Row(
- children: [
- Text(
- 'Platform:',
- style: TextStyle(backgroundColor: Colors.lightBlueAccent),
- textAlign: TextAlign.center,
- ),
- SizedBox(
- width: 136,
- child: Expanded(
- child: DropdownButtonFormField<String>(
- decoration: InputDecoration(
- hintText: "Select an platform",
- contentPadding: EdgeInsets.all(0.0)),
- onChanged: (item) {
- setState(() => this.selectedPlatform = item);
- },
- key: platformKey,
- value: selectedPlatform,
- items: platforms
- .map((e) => DropdownMenuItem<String>(
- child: Container(
- child: Text(e),
- width: 100,
- ),
- value: e,
- ))
- .toList(),
- ),
- )),
- TextButton.icon(
- style: ButtonStyle(
- backgroundColor:
- MaterialStateProperty.all(Colors.lightBlueAccent)),
- onPressed: () => onBuild(context),
- icon: Icon(Icons.rule_rounded),
- label: Text(
- "Build",
- style: TextStyle(color: Colors.white),
- )),
- ],
- ),
- Row(
- children: [
- TextButton.icon(
- onPressed: () => setState(() {}),
- icon: Icon(Icons.search),
- label: Text("Search")),
- ],
- ),
- Expanded(
- child: Center(
- child: FutureBuilder<List<BuildHistory>>(
- key: listKey,
- future: future,
- builder: (context, snapshot) {
- if (snapshot.hasError) {
- return const Center(
- child: Text('An error has occurred!'),
- );
- } else if (snapshot.hasData) {
- return BuildHistoryList(
- token: "accessToken", histories: snapshot.data!);
- } else {
- return const Center(
- child: CircularProgressIndicator(),
- );
- }
- },
- ),
- )),
- ],
- ),
- ),
- );
- }
- Future<List<BuildHistory>> fetchBuildHistories() async {
- try {
- var service = GetIt.instance.get<BuildService>();
- return List.empty();
- } catch (ex) {
- Logger.error('fetchBuildHistories ex:' + ex.toString());
- return List.empty();
- }
- }
- void onBuild(context) {
- try {
- var service = GetIt.instance.get<BuildService>();
- service.Run();
- } catch (ex) {
- Logger.error("onBuild ex:${ex}");
- }
- }
- }
|