File size: 1,372 Bytes
aa0155d
 
 
 
 
3cc7c13
aa0155d
 
3cc7c13
aa0155d
 
 
 
 
 
 
3cc7c13
 
 
 
aa0155d
 
 
3cc7c13
 
 
 
 
aa0155d
 
3cc7c13
 
aa0155d
3cc7c13
aa0155d
 
 
3cc7c13
aa0155d
 
3cc7c13
 
 
 
 
 
aa0155d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// lib/models/video_orientation.dart

/// Enum representing the orientation of a video clip.
enum VideoOrientation {
  /// Landscape orientation (horizontal, typically 16:9)
  LANDSCAPE,
  
  /// Portrait orientation (vertical, typically 9:16)
  PORTRAIT
}

/// Extension methods for VideoOrientation enum
extension VideoOrientationExtension on VideoOrientation {
  /// Get the string representation of the orientation
  String get name {
    switch (this) {
      case VideoOrientation.LANDSCAPE:
        return 'LANDSCAPE';
      case VideoOrientation.PORTRAIT:
        return 'PORTRAIT';
    }
  }
  
  /// Value for API communication
  String get value {
    return name;
  }
  
  /// Get the orientation from a string
  static VideoOrientation fromString(String? str) {
    if (str?.toUpperCase() == 'PORTRAIT') {
      return VideoOrientation.PORTRAIT;
    }
    return VideoOrientation.LANDSCAPE; // Default to landscape
  }
  
  /// Whether this orientation is portrait
  bool get isPortrait => this == VideoOrientation.PORTRAIT;
  
  /// Whether this orientation is landscape
  bool get isLandscape => this == VideoOrientation.LANDSCAPE;
}

/// Helper function to determine orientation from width and height
VideoOrientation getOrientationFromDimensions(int width, int height) {
  return width >= height ? VideoOrientation.LANDSCAPE : VideoOrientation.PORTRAIT;
}