Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/lab7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lab 7 CI

on:
push:
branches:
- lab7
pull_request:
branches:
- lab7

jobs:
build-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.23.0-0.1.pre
- run: flutter pub get
- run: flutter analyze lib/templates/lab7/main.dart
- run: flutter test test/lab7_test.dart
- run: flutter build web --release lib/templates/lab7/main.dart

build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.23.0-0.1.pre
- run: flutter pub get
- run: flutter analyze lib/templates/lab7/main.dart
- run: flutter test test/lab7_test.dart
- run: flutter build windows --release lib/templates/lab7/main.dart
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
FROM debian:latest AS build-env

RUN apt-get update
RUN apt-get update -y && apt-get upgrade -y
# Add apt-get install for flutter linux from
# https://docs.flutter.dev/get-started/install/linux/desktop?tab=download
RUN apt-get install -y curl git unzip xz-utils zip libglu1-mesa
RUN apt-get clean


# TODO clone original flutter github repo
RUN git -v
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter

ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
ENV PATH="${PATH}:/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin"

RUN flutter doctor -v

Expand All @@ -21,7 +25,10 @@ COPY . /app/
WORKDIR /app/

# TODO get dependencies
RUN flutter pub get

# TODO build web from needed file
RUN flutter build web --release ./lib/templates/lab7/main.dart

FROM nginx:1.21.1-alpine

Expand Down
5 changes: 5 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
include: package:flutter_lints/flutter.yaml

analyzer:
errors:
avoid_unnecessary_containers: ignore
prefer_const_constructors: ignore
81 changes: 55 additions & 26 deletions lib/templates/lab1/lab1.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void main() => runApp(const Lab1());

Expand All @@ -22,13 +21,16 @@ class LAb1HomePage extends StatelessWidget {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
leading: const Icon(Icons.stars),
title: const Text('Lab 1'),
backgroundColor: Colors.teal,
elevation: 4,
),
body: myWidget(),
body: myWidget(context),
);
}

Widget myWidget() {
Widget myWidget(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Expand All @@ -47,7 +49,7 @@ class LAb1HomePage extends StatelessWidget {
const SizedBox(
height: 25,
),
exercise4(),
exercise4(context),
const SizedBox(
height: 25,
),
Expand All @@ -59,45 +61,72 @@ class LAb1HomePage extends StatelessWidget {

Widget exercise1() {
return const Text(
"Hello, Flutter!",
'Flutter Rules',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
color: Colors.lightBlue,
fontWeight: FontWeight.bold),
);
fontWeight: FontWeight.w900,
fontSize: 37.0,
color: Colors.teal,
),
);
}

Widget exercise2() {
return const Icon(
Icons.favorite,
size: 100,
color: Colors.red,
Icons.tv,
color: Colors.teal,
size: 42.0,
);
}

Widget exercise3() {
return const Image(
width: 100, height: 100, image: NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg'),
return Image.network(
'https://i.pinimg.com/736x/b7/43/26/b74326865ca5feff316e6416a1b73ddc.jpg',
width: 48.0,
height: 64.0,
fit: BoxFit.fill,
);
}

printPressed() {
print("Pressed");
}

Widget exercise4() {
Widget exercise4(BuildContext context) {
return TextButton(
onPressed: printPressed,
child: const Text('CLICK ME!'),
);
style: TextButton.styleFrom(
foregroundColor: Colors.tealAccent[700],
),
child: const Text('Press me'),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Pressed'),
));
},
);
}

Widget exercise5() {
return Column(
children: [
Container(color: Colors.blue, padding: const EdgeInsets.all(50), child: const Text("This is home Icon in Container!")),
Container(color: Colors.red, margin: const EdgeInsets.all(100), child: const Icon(Icons.home)),
]
children: <Widget>[
Container(
padding: const EdgeInsets.all(16.0),
decoration: const BoxDecoration(
color: Colors.teal,
borderRadius: BorderRadius.all(Radius.circular(30.0)),
),
child: const Text(
'There\'s a Column!',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w700),
),
),
Container(
padding: const EdgeInsets.all(32.0),
margin: const EdgeInsets.fromLTRB(4.0, 16.0, 4.0, 8.0),
decoration: const FlutterLogoDecoration(),
child: const Icon(
Icons.egg_sharp,
color: Colors.blue,
size: 25.0,
),
),
],
);
}
}
171 changes: 164 additions & 7 deletions lib/templates/lab2/lab2.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,172 @@
class Book {
// your code here
import 'package:flutter/material.dart';

void main() => runApp(const Lab2());

class Lab2 extends StatelessWidget {
const Lab2({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
leading: const Icon(Icons.stars),
title: const Text('Lab 2'),
backgroundColor: Colors.teal,
elevation: 4,
),
body: SingleChildScrollView(
child: Column(
children: [
element(ex1()),
element(ex2()),
element(ex3()),
element(ex4()),
element(ex5()),
],
),
),
));
}

Widget element(Widget widget) {
return Container(
margin: const EdgeInsets.all(16.0),
child: widget,
);
}

Widget ex1() {
List<Book> books = [
Book('Book1', 'Author1', 13),
Book('Book2', 'Author2', 42),
Book('Book3', 'Author3', 37)
];
List<Text> details = [];
for (final book in books) {
details.add(Text(book.bookDetails()));
}
return Column(
children: details,
);
}

Widget ex2() {
List<FictionBook> books = [
FictionBook('Book1', 'Author1', 13, 'Thriller'),
FictionBook('Book2', 'Author2', 42, 'Comedy'),
FictionBook('Book3', 'Author3', 37, 'Detective')
];
List<Text> details = [];
for (final book in books) {
details.add(Text(book.bookDetails()));
}
return Column(
children: details,
);
}

Widget ex3() {
List<Book> books = [
Book('Book1', 'Author1', 13),
Book('Book2', 'Author2', 42),
Book('Book3', 'Author3', 37)
];
List<Text> details = [];
for (final book in books) {
details.add(Text(book.toJson().toString()));
}
return Column(
children: details,
);
}

Widget ex4() {
return Column(
children: [
Text(
'length: 15, width 22, area: ${calculateArea(width: 22, length: 15)}'),
Text(
'radius: 37, area: ${calculateArea(length: 37, width: 0, shape: 'circle')}')
],
);
}

Widget ex5() {
List<User> users = [
User('Book1', email: 'Author1', age: 13),
User('Book2', age: 42),
User('Book3', email: 'Author3')
];
List<Text> details = [];
for (final book in users) {
details.add(Text(book.printUserDetails()));
}
return Column(
children: details,
);
}
}

class FictionBook {
// your code here
class Book with JsonSerializable {
String title;
String author;
int numOfPages;

Book(this.title, this.author, this.numOfPages);

String bookDetails() {
return "$author - $title ($numOfPages)";
}
}

class FictionBook extends Book {
String genre;

FictionBook(super.title, super.author, super.numOfPages, this.genre);

@override
String bookDetails() {
return "$author - $title <$genre> ($numOfPages)";
}
}

mixin JsonSerializable {
// your code here
Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};
switch (runtimeType) {
case const (Book):
Book book = this as Book;
json['title'] = book.title;
json['author'] = book.author;
json['numOfPages'] = book.numOfPages;
return json;
}
return json;
}
}

class User{
// your code here
double calculateArea(
{required double width,
required double length,
String shape = 'rectangle'}) {
switch (shape) {
case 'circle':
return 3.14 * length * length;
default:
return length * width;
}
}

class User {
String name;
int? age;
String? email;

User(this.name, {this.age, this.email});

String printUserDetails() {
return 'Name: $name\nAge: ${age ?? "N/A"}\nEmail: ${email ?? "N/A"}';
}
}
Loading